Class: Brightpearl::Contact

Inherits:
Resource show all
Extended by:
APIOperations::Get, APIOperations::Options, APIOperations::Patch, APIOperations::Post
Defined in:
lib/brightpearl/resources/contact.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Get

get

Methods included from APIOperations::Post

post

Methods included from APIOperations::Patch

patch

Methods included from APIOperations::Options

options

Methods inherited from Resource

send_request, to_query

Constructor Details

#initialize(ara) ⇒ Contact

ARA => API Record Array



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/brightpearl/resources/contact.rb', line 35

def initialize(ara)
  @id = ara[0]
  @primary_email = ara[1]
  @secondary_email = ara[2]
  @tertiary_email = ara[3]
  @first_name = ara[4]
  @last_name = ara[5]
  @is_supplier = ara[6]
  @company_name = ara[7]
  @is_staff = ara[8]
  @is_customer = ara[9]
  @created_on = ara[10]
  @updated_on = ara[11]
  @last_contacted_on = ara[12]
  @last_ordered_on = ara[13]
  @nominal_code = ara[14]
  @is_primary = ara[15]
  @pri = ara[16]
  @sec = ara[17]
  @mob = ara[18]
  @exact_company_name = ara[19]
  @title = ara[20]
end

Instance Attribute Details

#company_nameObject

Returns the value of attribute company_name.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def company_name
  @company_name
end

#created_onObject

Returns the value of attribute created_on.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def created_on
  @created_on
end

#exact_company_nameObject

Returns the value of attribute exact_company_name.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def exact_company_name
  @exact_company_name
end

#first_nameObject

Returns the value of attribute first_name.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def first_name
  @first_name
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def id
  @id
end

#is_customerObject

Returns the value of attribute is_customer.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def is_customer
  @is_customer
end

#is_primaryObject

Returns the value of attribute is_primary.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def is_primary
  @is_primary
end

#is_staffObject

Returns the value of attribute is_staff.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def is_staff
  @is_staff
end

#is_supplierObject

Returns the value of attribute is_supplier.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def is_supplier
  @is_supplier
end

#last_contacted_onObject

Returns the value of attribute last_contacted_on.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def last_contacted_on
  @last_contacted_on
end

#last_nameObject

Returns the value of attribute last_name.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def last_name
  @last_name
end

#last_ordered_onObject

Returns the value of attribute last_ordered_on.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def last_ordered_on
  @last_ordered_on
end

#mobObject

Returns the value of attribute mob.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def mob
  @mob
end

#nominal_codeObject

Returns the value of attribute nominal_code.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def nominal_code
  @nominal_code
end

#priObject

Returns the value of attribute pri.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def pri
  @pri
end

#primary_emailObject

Returns the value of attribute primary_email.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def primary_email
  @primary_email
end

#secObject

Returns the value of attribute sec.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def sec
  @sec
end

#secondary_emailObject

Returns the value of attribute secondary_email.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def secondary_email
  @secondary_email
end

#tertiary_emailObject

Returns the value of attribute tertiary_email.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def tertiary_email
  @tertiary_email
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def title
  @title
end

#updated_onObject

Returns the value of attribute updated_on.



9
10
11
# File 'lib/brightpearl/resources/contact.rb', line 9

def updated_on
  @updated_on
end

Class Method Details

.resource_pathObject



16
17
18
# File 'lib/brightpearl/resources/contact.rb', line 16

def resource_path
  "contact-service/contact"
end

.search(query_params = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/brightpearl/resources/contact.rb', line 26

def search(query_params = {})
  response = send_request(path: "contact-service/contact-search?#{to_query(query_params)}", method: :get)
  return response.merge({ # modify final payload to set search results as objects
    records: response[:payload]["response"]["results"].map { |item| Contact.new(item) },
   })
end