Class: Sellsy::Contact
- Inherits:
-
Object
- Object
- Sellsy::Contact
- Defined in:
- lib/sellsy/contact.rb
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
Returns the value of attribute birth_date.
-
#email ⇒ Object
Returns the value of attribute email.
-
#fax ⇒ Object
Returns the value of attribute fax.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#mobile ⇒ Object
Returns the value of attribute mobile.
-
#name ⇒ Object
Returns the value of attribute name.
-
#role ⇒ Object
Returns the value of attribute role.
-
#telephone ⇒ Object
Returns the value of attribute telephone.
-
#third_id ⇒ Object
Returns the value of attribute third_id.
-
#title ⇒ Object
Returns the value of attribute title.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#birth_date ⇒ Object
Returns the value of attribute birth_date.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def birth_date @birth_date end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def email @email end |
#fax ⇒ Object
Returns the value of attribute fax.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def fax @fax end |
#first_name ⇒ Object
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def first_name @first_name end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def id @id end |
#last_name ⇒ Object
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def last_name @last_name end |
#mobile ⇒ Object
Returns the value of attribute mobile.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def mobile @mobile end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def name @name end |
#role ⇒ Object
Returns the value of attribute role.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def role @role end |
#telephone ⇒ Object
Returns the value of attribute telephone.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def telephone @telephone end |
#third_id ⇒ Object
Returns the value of attribute third_id.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def third_id @third_id end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def title @title end |
#website ⇒ Object
Returns the value of attribute website.
5 6 7 |
# File 'lib/sellsy/contact.rb', line 5 def website @website end |
Class Method Details
.find(people_id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sellsy/contact.rb', line 23 def self.find(people_id) command = { 'method' => 'Peoples.getOne', 'params' => { 'id' => people_id } } response = MultiJson.load(Sellsy::Api.request command) contact = Contact.new if response['response'] value = response['response'] contact.id = value['id'] end contact end |
.find_by_contact(contact_id) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sellsy/contact.rb', line 42 def self.find_by_contact(contact_id) command = { 'method' => 'Peoples.getOne', 'params' => { 'thirdcontactid' => contact_id } } response = MultiJson.load(Sellsy::Api.request command) contact = Contact.new if response['response'] value = response['response'] contact.id = value['id'] end contact end |
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sellsy/contact.rb', line 8 def create command = { 'method' => 'Peoples.create', 'params' => { 'people' => to_params } } response = MultiJson.load(Sellsy::Api.request command) @id = response['response']['id'] if response['response'] response['status'] == 'success' end |
#get_addresses ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sellsy/contact.rb', line 77 def get_addresses command = { 'method' => 'Peoples.getAddresses', 'params' => { 'id' => id } } response = MultiJson.load(Sellsy::Api.request command) client = Contact.new if response['response'] value = response['response'] client.id = value['id'] end client end |
#to_params ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sellsy/contact.rb', line 61 def to_params { 'civil' => civil_enum(@title), 'name' => @last_name || @name, 'forename' => @first_name, 'email' => @email, 'tel' => @telephone, 'fax' => @fax, 'mobile' => @mobile, 'web' => @website, 'position' => @role, 'birthdate' => @birth_date.blank? ? '' : Date.parse(@birth_date).to_datetime.to_i, 'thirdids' => @third_id.blank? ? nil : [@third_id] } end |