module SageoneSdk::Client::Contacts

Represents the contacts for the authenticated user's business.

Public Instance Methods

contact(id, options = {}) click to toggle source

@return [object] Returns the contact with the given id.

# File lib/sageone_sdk/client/contacts.rb, line 12
def contact(id, options = {})
  get "contacts/#{id}", options
end
contacts(options = {}) click to toggle source

@return [object] Returns all contacts for the authenticated user's business.

# File lib/sageone_sdk/client/contacts.rb, line 7
def contacts(options = {})
  paginate "contacts", options
end
create_contact(type, data, options = {}) click to toggle source

Creates a contact record with the data provided. @example Create a new contact record

@client.create_contact(1, {"name" => "My new customer",
                           "company_name" => "Sage UK Ltd"})

@param type [integer] The contact type id. 1 = Customer, 2 = Supplier. @param data [hash] The contact record information. @param options [hash]

# File lib/sageone_sdk/client/contacts.rb, line 37
def create_contact(type, data, options = {})
  data['contact_type_id'] = type

  post "contacts", :contact => data
end
create_customer(data, options = {}) click to toggle source

Creates a customer record with the data provided. @example Create a new customer record

@client.create_customer({"name" => "My new customer",
                         "company_name" => "Sage UK Ltd"})

@param data [hash] The customer record information. @param options [hash]

# File lib/sageone_sdk/client/contacts.rb, line 49
def create_customer(data, options = {})
  create_contact(ContactTypes::CUSTOMER, data, options)
end
create_supplier(data, options = {}) click to toggle source

Creates a supplier record with the data provided. @example Create a new supplier record

@client.create_supplier({"name" => "My new supplier",
                         "company_name" => "Sage UK Ltd"})

@param data [hash] The supplier record information. @param options [hash]

# File lib/sageone_sdk/client/contacts.rb, line 59
def create_supplier(data, options = {})
  create_contact(ContactTypes::SUPPLIER, data, options)
end
customers(options = {}) click to toggle source

@return [object] Returns all customers for the authenticated user's business.

# File lib/sageone_sdk/client/contacts.rb, line 17
def customers(options = {})
  options["contact_type_id"] = ContactTypes::CUSTOMER

  contacts(options)
end
delete_contact(id, options = {}) click to toggle source

Deletes the given contact record. @param id [integer] The id of the contact record to delete. @param options [hash]

# File lib/sageone_sdk/client/contacts.rb, line 77
def delete_contact(id, options = {})
  delete "contacts/#{id}"
end
suppliers(options = {}) click to toggle source

@return [object] Returns all suppliers for the authenticated user's business.

# File lib/sageone_sdk/client/contacts.rb, line 24
def suppliers(options = {})
  options["contact_type_id"] = ContactTypes::SUPPLIER

  contacts(options)
end
update_contact(id, data, options = {}) click to toggle source

Updates the given contact record with the data provided. @example Update contact record with id 1234

@client.update_contact(1234, {"name" => "Updated contact name",
                              "company_name" => "Updated company name"})

@param id [integer] The id of the contact record to update. @param data [hash] The contact record information to update. @param options [hash]

# File lib/sageone_sdk/client/contacts.rb, line 70
def update_contact(id, data, options = {})
  put "contacts/#{id}", :contact => data
end