Class: Sellsy::Customer
- Inherits:
-
Object
- Object
- Sellsy::Customer
- Defined in:
- lib/sellsy/customer.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#ape ⇒ Object
Returns the value of attribute ape.
-
#apidae_member_id ⇒ Object
Returns the value of attribute apidae_member_id.
-
#category ⇒ Object
Returns the value of attribute category.
-
#college_type ⇒ Object
Returns the value of attribute college_type.
-
#contact ⇒ Object
Returns the value of attribute contact.
-
#contacts ⇒ Object
Returns the value of attribute contacts.
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#legal_type ⇒ Object
Returns the value of attribute legal_type.
-
#main_contact_id ⇒ Object
Returns the value of attribute main_contact_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#person_type ⇒ Object
Returns the value of attribute person_type.
-
#siret ⇒ Object
Returns the value of attribute siret.
-
#structure_name ⇒ Object
Returns the value of attribute structure_name.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def address @address end |
#ape ⇒ Object
Returns the value of attribute ape.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def ape @ape end |
#apidae_member_id ⇒ Object
Returns the value of attribute apidae_member_id.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def apidae_member_id @apidae_member_id end |
#category ⇒ Object
Returns the value of attribute category.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def category @category end |
#college_type ⇒ Object
Returns the value of attribute college_type.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def college_type @college_type end |
#contact ⇒ Object
Returns the value of attribute contact.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def contact @contact end |
#contacts ⇒ Object
Returns the value of attribute contacts.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def contacts @contacts end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def id @id end |
#legal_type ⇒ Object
Returns the value of attribute legal_type.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def legal_type @legal_type end |
#main_contact_id ⇒ Object
Returns the value of attribute main_contact_id.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def main_contact_id @main_contact_id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def name @name end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def payment_method @payment_method end |
#person_type ⇒ Object
Returns the value of attribute person_type.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def person_type @person_type end |
#siret ⇒ Object
Returns the value of attribute siret.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def siret @siret end |
#structure_name ⇒ Object
Returns the value of attribute structure_name.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def structure_name @structure_name end |
#website ⇒ Object
Returns the value of attribute website.
5 6 7 |
# File 'lib/sellsy/customer.rb', line 5 def website @website end |
Class Method Details
.all ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/sellsy/customer.rb', line 93 def self.all command = { 'method' => 'Client.getList', 'params' => {} } response = MultiJson.load(Sellsy::Api.request command) clients = [] if response['response'] response['response']['result'].each do |key, value| client = Customer.new client.id = key client.name = value['fullName'] clients << client end end clients end |
.find(id) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sellsy/customer.rb', line 48 def self.find(id) command = { 'method' => 'Client.getOne', 'params' => { 'clientid' => id } } response = MultiJson.load(Sellsy::Api.request command) client = Customer.new if response['response'] value = response['response']['client'] client.id = value['id'] client.name = value['name'] client.contacts = response['response']['contacts'] end client end |
.search(params) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/sellsy/customer.rb', line 70 def self.search(params) command = { 'method' => 'Client.getList', 'params' => params } response = MultiJson.load(Sellsy::Api.request command) clients = [] if response['response'] response['response']['result'].each do |key, value| client = Customer.new client.id = key client.name = value['fullName'] client.email = value['email'] client.siret = value['siret'] clients << client end end clients end |
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sellsy/customer.rb', line 9 def create command = { 'method' => 'Client.create', 'params' => to_params } response = MultiJson.load(Sellsy::Api.request command) @id = response['response'] response['status'] == 'success' end |
#to_params ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sellsy/customer.rb', line 30 def to_params { 'clientid' => @id, 'third' => { 'name' => person_type == 'pp' ? @name : @structure_name, 'type' => person_type == 'pp' ? 'person' : 'corporation', 'ident' => apidae_member_id, 'email' => @email, 'web' => @website, 'siret' => @siret, 'corpType' => @legal_type, 'apenaf' => @ape }, 'contact' => contact ? contact.to_params : {}, 'address' => address ? address.to_params : {} } end |