sellsy-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,67 @@
1
+ require 'multi_json'
2
+
3
+ module Sellsy
4
+ class Contact
5
+ attr_accessor :id
6
+ attr_accessor :name, :thirdid, :forename, :email, :position
7
+
8
+ def create
9
+ command = {
10
+ 'method' => 'Peoples.create',
11
+ 'params' => {
12
+ 'people' => {
13
+ 'name' => @name,
14
+ 'forename' => @forename,
15
+ 'email' => @email,
16
+ 'position' => @position,
17
+ 'thirdids' => [@thirdid]
18
+ }
19
+ }
20
+ }
21
+
22
+ response = MultiJson.load(Sellsy::Api.request command)
23
+
24
+ @id = response['response']['id'] if response['response']
25
+
26
+ response['status'] == 'success'
27
+ end
28
+
29
+ def self.find(id)
30
+ command = {
31
+ 'method' => 'Peoples.getOne',
32
+ 'params' => {
33
+ 'id' => id
34
+ }
35
+ }
36
+
37
+ response = MultiJson.load(Sellsy::Api.request command)
38
+ contact = Contact.new
39
+
40
+ if response['response']
41
+ value = response['response']
42
+ contact.id = value['id']
43
+ end
44
+
45
+ contact
46
+ end
47
+
48
+ def get_addresses
49
+ command = {
50
+ 'method' => 'Peoples.getAddresses',
51
+ 'params' => {
52
+ 'id' => id
53
+ }
54
+ }
55
+
56
+ response = MultiJson.load(Sellsy::Api.request command)
57
+ client = Contact.new
58
+
59
+ if response['response']
60
+ value = response['response']
61
+ client.id = value['id']
62
+ end
63
+
64
+ client
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,42 @@
1
+ require 'multi_json'
2
+
3
+ module Sellsy
4
+ class CustomField
5
+ attr_accessor :id, :value
6
+
7
+ def initialize(id, value)
8
+ @id = id
9
+ @value = value
10
+ end
11
+
12
+ def self.set_values(entity, *custom_fields)
13
+ command = {
14
+ 'method' => 'CustomFields.recordValues',
15
+ 'params' => {
16
+ 'linkedtype' => linked_type(entity),
17
+ 'linkedid' => entity.id,
18
+ 'values' => custom_fields.select {|cf| !cf.value.blank?}.map {|cf| {'cfid' => cf.id, 'value' => cf.value}}
19
+ }
20
+ }
21
+
22
+ response = MultiJson.load(Sellsy::Api.request command)
23
+
24
+ response['status'] == 'success'
25
+ end
26
+
27
+ def self.linked_type(entity)
28
+ case entity
29
+ when Customer
30
+ 'client'
31
+ when Prospect
32
+ 'prospect'
33
+ when Opportunity
34
+ 'opportunity'
35
+ when Document
36
+ 'document'
37
+ else
38
+ nil
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,140 @@
1
+ require 'multi_json'
2
+
3
+ module Sellsy
4
+ class Customer
5
+ attr_accessor :id, :title, :name, :first_name, :last_name, :structure_name, :category, :college_type, :siret,
6
+ :ape, :legal_type, :role, :birth_date, :address, :postal_code, :town, :country, :telephone, :email,
7
+ :website, :payment_method, :person_type, :apidae_member_id
8
+
9
+ def create
10
+ command = {
11
+ 'method' => 'Client.create',
12
+ 'params' => api_params
13
+ }
14
+
15
+ response = MultiJson.load(Sellsy::Api.request command)
16
+ @id = response['response']
17
+ response['status'] == 'success'
18
+ end
19
+
20
+ def update
21
+ command = {
22
+ 'method' => 'Client.update',
23
+ 'params' => api_params
24
+ }
25
+
26
+ response = MultiJson.load(Sellsy::Api.request command)
27
+ response['status'] == 'success'
28
+ end
29
+
30
+ def api_params
31
+ {
32
+ 'third' => {
33
+ 'name' => person_type == 'pp' ? @name : @structure_name,
34
+ 'type' => person_type == 'pp' ? 'person' : 'corporation',
35
+ 'ident' => apidae_member_id,
36
+ 'email' => @email,
37
+ 'web' => @website,
38
+ 'siret' => @siret,
39
+ 'corpType' => @legal_type,
40
+ 'apenaf' => @ape
41
+ },
42
+ 'contact' => {
43
+ 'civil' => civil_enum(@title),
44
+ 'name' => @last_name || @name,
45
+ 'forename' => @first_name,
46
+ 'email' => @email,
47
+ 'tel' => @telephone,
48
+ 'mobile' => @telephone,
49
+ 'position' => @role,
50
+ },
51
+ 'address' => {
52
+ 'name' => 'adresse souscription',
53
+ 'part1' => @address.split(/(\r\n?)/)[0],
54
+ 'part2' => @address.split(/(\r\n?)/)[0],
55
+ 'zip' => @postal_code,
56
+ 'town' => @town,
57
+ 'countrycode' => @country.upcase
58
+ }
59
+ }
60
+ end
61
+
62
+ def self.find(id)
63
+ command = {
64
+ 'method' => 'Client.getOne',
65
+ 'params' => {
66
+ 'clientid' => id
67
+ }
68
+ }
69
+
70
+ response = MultiJson.load(Sellsy::Api.request command)
71
+
72
+ client = Customer.new
73
+
74
+ if response['response']
75
+ value = response['response']['client']
76
+ client.id = value['id']
77
+ client.name = value['name']
78
+ client.joindate = value['joindate']
79
+ client.type = value['type']
80
+ end
81
+
82
+ client
83
+ end
84
+
85
+ def self.search(params)
86
+ command = {
87
+ 'method' => 'Client.getList',
88
+ 'params' => params
89
+ }
90
+
91
+ response = MultiJson.load(Sellsy::Api.request command)
92
+
93
+ clients = []
94
+ if response['response']
95
+ response['response']['result'].each do |key, value|
96
+ client = Customer.new
97
+ client.id = key
98
+ client.name = value['fullName']
99
+ clients << client
100
+ end
101
+ end
102
+
103
+ clients
104
+ end
105
+
106
+ def self.all
107
+ command = {
108
+ 'method' => 'Client.getList',
109
+ 'params' => {}
110
+ }
111
+
112
+ response = MultiJson.load(Sellsy::Api.request command)
113
+
114
+ clients = []
115
+ if response['response']
116
+ response['response']['result'].each do |key, value|
117
+ client = Customer.new
118
+ client.id = key
119
+ client.name = value['fullName']
120
+ clients << client
121
+ end
122
+ end
123
+
124
+ clients
125
+ end
126
+
127
+ private
128
+
129
+ def civil_enum(val)
130
+ case val
131
+ when 'M.'
132
+ 'man'
133
+ when 'Mme'
134
+ 'woman'
135
+ else
136
+ nil
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,185 @@
1
+ require 'multi_json'
2
+
3
+ module Sellsy
4
+ class Document
5
+ attr_accessor :id
6
+ attr_accessor :corp_name
7
+ attr_accessor :owner_full_name
8
+ attr_accessor :status
9
+ attr_accessor :identity
10
+
11
+ attr_accessor :total_amount_taxes_free
12
+ attr_accessor :taxes_amount_sum
13
+ attr_accessor :total_amount
14
+
15
+ attr_accessor :client_id
16
+ attr_accessor :packaging_name
17
+ attr_accessor :shipping_name
18
+ attr_accessor :amount
19
+ attr_accessor :unit_amount
20
+ attr_accessor :tax_rate
21
+
22
+ attr_accessor :doctype
23
+ attr_accessor :thirdid
24
+ attr_accessor :thirdname
25
+ attr_accessor :step
26
+ attr_accessor :ident
27
+ attr_accessor :subject
28
+ attr_accessor :notes
29
+ attr_accessor :rows
30
+ # {"status":"ok","filename":"","fileid":"0","nbpages":"1","thirdident":"","thirdname":"Alain","thirdid":"2655","thirdvatnum":"","contactId":"0","contactName":"","displayedDate":"0000-00-00","currencysymbol":"\u20ac","subject":"","docspeakerText":"Votre contact","corpaddressid":"36047","thirdaddressid":"36048","shipaddressid":"36049","rowsAmount":"0.000000000","discountPercent":"0.000000000","discountAmount":"0.000000000","rowsAmountDiscounted":"0.000000000","offerAmount":"0.000000000","rowsAmountAllInc":"0.000000000","packagingsAmount":"49.900000000","shippingsAmount":"60.000000000","totalAmountTaxesFree":"109.900000000","taxesAmountSum":"21.540400000","taxesAmountDetails":"a:1:{s:12:\"19.600000000\";s:12:\"21.540400000\";}","totalAmount":"131.440400000","payDateText":"","payDateCustom":"0000-00-00","payMediumsText":"a:1:{i:0;s:7:\"ch\u00e8que\";}","payCheckOrderText":"","payBankAccountText":"","shippingNbParcels":"0","shippingWeight":"0.000000000","shippingWeightUnit":"g","shippingVolume":"0.000000000","shippingTrackingNumber":"","shippingTrackingUrl":"","saveThirdPrefs":"N","displayShipAddress":"N","corpid":"2","ownerid":"2","linkedtype":"invoice","linkedid":"9512","created":"2012-03-21 14:30:32","prefsid":"14679","parentid":"0","docmapid":"11599","hasVat":"Y","doctypeid":"9512","step":"draft","isDeposit":"N","dueAmount":"131.440400000","currencyid":"1","currencyposition":"right","numberformat":"fr","numberdecimals":",","numberthousands":"","numberprecision":"2","formatted_dueAmount":"131,44 \u20ac","step_color":"pink","step_hex":"#C033DA","step_label":"Non envoy\u00e9e","step_css":"colorDraft","step_banner":"draft_f","step_id":"draft","displayed_payMediumsText":"ch\u00e8que","formatted_totalAmount":"131,44 \u20ac","formatted_totalAmountTaxesFree":"109,90 \u20ac","formatted_displayedDate":"04\/04\/2012","formatted_payDateCustom":"04\/04\/2012","noedit":"N"}
31
+
32
+ def self.get_link(docid, doctype)
33
+ command = {
34
+ 'method' => 'Document.getPublicLink_v2',
35
+ 'params' => {
36
+ 'doctype' => doctype,
37
+ 'docid' => docid
38
+ }
39
+ }
40
+ response = MultiJson.load(Sellsy::Api.request command)
41
+
42
+ if response['response']
43
+ value = response['response']
44
+ pdf = value['pdf']
45
+ end
46
+ pdf
47
+ end
48
+
49
+ def self.get_for_copy(docid, doctype)
50
+ command = {
51
+ 'method' => 'Document.getForCopy',
52
+ 'params' => {
53
+ 'doctype' => doctype,
54
+ 'docid' => docid
55
+ }
56
+ }
57
+ response = MultiJson.load(Sellsy::Api.request command)
58
+
59
+ if response['response']
60
+ estimate = response['response']
61
+ end
62
+ estimate
63
+ end
64
+
65
+ def self.find(docid, doctype)
66
+ command = {
67
+ 'method' => 'Document.getOne',
68
+ 'params' => {
69
+ 'doctype' => doctype,
70
+ 'docid' => docid
71
+ }
72
+ }
73
+ response = MultiJson.load(Sellsy::Api.request command)
74
+
75
+ if response['response']
76
+ estimate = response['response']
77
+ end
78
+ estimate
79
+ end
80
+
81
+ # {"status":"ok","filename":"","fileid":"0","nbpages":"1","thirdident":"","thirdname":"Alain","thirdid":"2655","thirdvatnum":"","contactId":"0","contactName":"","displayedDate":"0000-00-00","currencysymbol":"\u20ac","subject":"","docspeakerText":"Votre contact","corpaddressid":"36047","thirdaddressid":"36048","shipaddressid":"36049","rowsAmount":"0.000000000","discountPercent":"0.000000000","discountAmount":"0.000000000","rowsAmountDiscounted":"0.000000000","offerAmount":"0.000000000","rowsAmountAllInc":"0.000000000","packagingsAmount":"49.900000000","shippingsAmount":"60.000000000","totalAmountTaxesFree":"109.900000000","taxesAmountSum":"21.540400000","taxesAmountDetails":"a:1:{s:12:\"19.600000000\";s:12:\"21.540400000\";}","totalAmount":"131.440400000","payDateText":"","payDateCustom":"0000-00-00","payMediumsText":"a:1:{i:0;s:7:\"ch\u00e8que\";}","payCheckOrderText":"","payBankAccountText":"","shippingNbParcels":"0","shippingWeight":"0.000000000","shippingWeightUnit":"g","shippingVolume":"0.000000000","shippingTrackingNumber":"","shippingTrackingUrl":"","saveThirdPrefs":"N","displayShipAddress":"N","corpid":"2","ownerid":"2","linkedtype":"invoice","linkedid":"9512","created":"2012-03-21 14:30:32","prefsid":"14679","parentid":"0","docmapid":"11599","hasVat":"Y","doctypeid":"9512","step":"draft","isDeposit":"N","dueAmount":"131.440400000","currencyid":"1","currencyposition":"right","numberformat":"fr","numberdecimals":",","numberthousands":"","numberprecision":"2","formatted_dueAmount":"131,44 \u20ac","step_color":"pink","step_hex":"#C033DA","step_label":"Non envoy\u00e9e","step_css":"colorDraft","step_banner":"draft_f","step_id":"draft","displayed_payMediumsText":"ch\u00e8que","formatted_totalAmount":"131,44 \u20ac","formatted_totalAmountTaxesFree":"109,90 \u20ac","formatted_displayedDate":"04\/04\/2012","formatted_payDateCustom":"04\/04\/2012","noedit":"N"}
82
+
83
+ def self.create(document)
84
+ command = {
85
+ 'method' => 'Document.create',
86
+ 'params' => {
87
+ 'document' => {
88
+ 'doctype' => document.doctype,
89
+ # 'parentId' => 'parentId',
90
+ 'thirdid' => document.thirdid,
91
+ 'ownerid' => document.author,
92
+ # 'displayedDate' => 'displayedDate',
93
+ 'subject' => document.subject,
94
+ 'notes' => document.notes,
95
+ # 'tags' => 'document_tags',
96
+ # 'displayShipAddress' => 'displayshippaddress_enum',
97
+ # 'rateCategory' => 'rateCategory',
98
+ # 'globalDiscount' => 'globalDiscount',
99
+ # 'globalDiscountUnit' => 'globalDiscountUnit',
100
+ # 'hasDoubleVat' => 'hasDoubleVat',
101
+ # 'currency' => 'currency',
102
+ 'doclayout' => '52100',
103
+ # 'payMediums' => 'payMediums',
104
+ 'docspeakerStaffId' => document.author
105
+ #},
106
+ },
107
+ # 'paydate' => {
108
+ # 'id' => 'paydate_id',
109
+ # 'xdays' => 'paydate_xdays',
110
+ # 'endmonth' => 'paydate_endmonth',
111
+ # 'scaledDetails' => 'paydate_scaledDetails',
112
+ # 'custom' => 'paydate_custom'
113
+ # },
114
+ # 'thirdaddress' => {
115
+ # 'id' => 'thirdaddress_id'
116
+ # },
117
+ # 'shipaddress' => {
118
+ # 'id' => 'shipaddress_id'
119
+ # },
120
+ 'row' => document.rows
121
+ #'row' => {}
122
+ }
123
+ }
124
+
125
+ response = MultiJson.load(Sellsy::Api.request command)
126
+ puts response.inspect
127
+ @doc_id = response['response']['doc_id'] if response['response']
128
+ puts "doc_id = " + @doc_id.to_s
129
+ @doc_id
130
+ end
131
+
132
+ def self.search(params)
133
+ command = {
134
+ 'method' => 'Document.getList',
135
+ 'params' => params
136
+ }
137
+ puts params
138
+ response = MultiJson.load(Sellsy::Api.request command)
139
+ puts response.inspect
140
+
141
+ documents = []
142
+ if response['response']
143
+ response['response']['result'].each do |key, value|
144
+ document = Document.new
145
+ document.id = key
146
+ document.ident = value['ident']
147
+ document.step = value['step']
148
+ document.subject = value['subject']
149
+ document.thirdname = value['thirdname']
150
+ documents << document
151
+ end
152
+ end
153
+
154
+ documents
155
+ end
156
+
157
+ def self.linked_documents(docid, doctype)
158
+ command = {
159
+ 'method' => 'Document.getLinkedDocuments',
160
+ 'params' => {
161
+ 'doctype' => doctype,
162
+ 'docid' => docid
163
+ }
164
+ }
165
+ response = MultiJson.load(Sellsy::Api.request command)
166
+ puts "response"
167
+ puts response['response']['directChildren'].inspect
168
+ documents = []
169
+ if response['response']
170
+ response['response']['directChildren'].each do |key, value|
171
+ document = Document.new
172
+ document.id = value['id'].to_i
173
+ document.ident = value['ident']
174
+ document.step = value['step']
175
+ document.subject = value['subject']
176
+ documents << document
177
+ end
178
+ end
179
+
180
+ documents
181
+ end
182
+
183
+ end
184
+ end
185
+
@@ -0,0 +1,156 @@
1
+ require 'multi_json'
2
+
3
+ module Sellsy
4
+ class Invoice
5
+ attr_accessor :id
6
+ attr_accessor :corp_name
7
+ attr_accessor :owner_full_name
8
+ attr_accessor :status
9
+ attr_accessor :identity
10
+
11
+ attr_accessor :total_amount_taxes_free
12
+ attr_accessor :taxes_amount_sum
13
+ attr_accessor :total_amount
14
+
15
+ attr_accessor :client_id
16
+ attr_accessor :packaging_name
17
+ attr_accessor :shipping_name
18
+ attr_accessor :amount
19
+ attr_accessor :unit_amount
20
+ attr_accessor :tax_rate
21
+
22
+ # {"status":"ok","filename":"","fileid":"0","nbpages":"1","thirdident":"","thirdname":"Alain","thirdid":"2655","thirdvatnum":"","contactId":"0","contactName":"","displayedDate":"0000-00-00","currencysymbol":"\u20ac","subject":"","docspeakerText":"Votre contact","corpaddressid":"36047","thirdaddressid":"36048","shipaddressid":"36049","rowsAmount":"0.000000000","discountPercent":"0.000000000","discountAmount":"0.000000000","rowsAmountDiscounted":"0.000000000","offerAmount":"0.000000000","rowsAmountAllInc":"0.000000000","packagingsAmount":"49.900000000","shippingsAmount":"60.000000000","totalAmountTaxesFree":"109.900000000","taxesAmountSum":"21.540400000","taxesAmountDetails":"a:1:{s:12:\"19.600000000\";s:12:\"21.540400000\";}","totalAmount":"131.440400000","payDateText":"","payDateCustom":"0000-00-00","payMediumsText":"a:1:{i:0;s:7:\"ch\u00e8que\";}","payCheckOrderText":"","payBankAccountText":"","shippingNbParcels":"0","shippingWeight":"0.000000000","shippingWeightUnit":"g","shippingVolume":"0.000000000","shippingTrackingNumber":"","shippingTrackingUrl":"","saveThirdPrefs":"N","displayShipAddress":"N","corpid":"2","ownerid":"2","linkedtype":"invoice","linkedid":"9512","created":"2012-03-21 14:30:32","prefsid":"14679","parentid":"0","docmapid":"11599","hasVat":"Y","doctypeid":"9512","step":"draft","isDeposit":"N","dueAmount":"131.440400000","currencyid":"1","currencyposition":"right","numberformat":"fr","numberdecimals":",","numberthousands":"","numberprecision":"2","formatted_dueAmount":"131,44 \u20ac","step_color":"pink","step_hex":"#C033DA","step_label":"Non envoy\u00e9e","step_css":"colorDraft","step_banner":"draft_f","step_id":"draft","displayed_payMediumsText":"ch\u00e8que","formatted_totalAmount":"131,44 \u20ac","formatted_totalAmountTaxesFree":"109,90 \u20ac","formatted_displayedDate":"04\/04\/2012","formatted_payDateCustom":"04\/04\/2012","noedit":"N"}
23
+
24
+ def create(invoice)
25
+ command = {
26
+ 'method' => 'Document.create',
27
+ 'params' => {
28
+ 'document' => {
29
+ 'doctype' => 'invoice',
30
+ # 'parentId' => 'parentId',
31
+ 'thirdid' => invoice.client_id
32
+ # 'displayedDate' => 'displayedDate',
33
+ # 'subject' => 'document_subject',
34
+ # 'notes' => 'document_notes',
35
+ # 'tags' => 'document_tags',
36
+ # 'displayShipAddress' => 'displayshippaddress_enum',
37
+ # 'rateCategory' => 'rateCategory',
38
+ # 'globalDiscount' => 'globalDiscount',
39
+ # 'globalDiscountUnit' => 'globalDiscountUnit',
40
+ # 'hasDoubleVat' => 'hasDoubleVat',
41
+ # 'currency' => 'currency',
42
+ # 'doclayout' => 'doclayout',
43
+ # 'payMediums' => 'payMediums'
44
+ },
45
+ # 'paydate' => {
46
+ # 'id' => 'paydate_id',
47
+ # 'xdays' => 'paydate_xdays',
48
+ # 'endmonth' => 'paydate_endmonth',
49
+ # 'scaledDetails' => 'paydate_scaledDetails',
50
+ # 'custom' => 'paydate_custom'
51
+ # },
52
+ # 'thirdaddress' => {
53
+ # 'id' => 'thirdaddress_id'
54
+ # },
55
+ # 'shipaddress' => {
56
+ # 'id' => 'shipaddress_id'
57
+ # },
58
+ 'row' => {
59
+ '1' => {
60
+ 'row_type' => 'packaging',
61
+ 'row_packaging' => invoice.packaging_name,
62
+ 'row_name' => 'row_name',
63
+ 'row_unitAmount' => invoice.unit_amount,
64
+ 'row_tax' => invoice.tax_rate
65
+ # 'row_taxid' => 'row_taxid',
66
+ # 'row_tax2id' => 'row_tax2id',
67
+ # 'row_qt' => 'row_quantity',
68
+ # 'row_isOption' => 'row_option',
69
+ # 'row_discount' => 'row_discount',
70
+ # 'row_discountUnit' => 'row_discountUnit'
71
+ },
72
+ '2' => {
73
+ 'row_type' => 'shipping',
74
+ 'row_shipping' => invoice.shipping_name,
75
+ # 'row_name' => 'row_name',
76
+ 'row_unitAmount' => invoice.unit_amount,
77
+ 'row_tax' => invoice.tax_rate,
78
+ # 'row_taxid' => 'row_taxid',
79
+ 'row_tax2id' => invoice.quantity
80
+ # 'row_qt' => 'row_quantity',
81
+ # 'row_isOption' => 'row_option',
82
+ # 'row_discount' => 'row_discount',
83
+ # 'row_discountUnit' => 'row_discountUnit'
84
+ }
85
+ # '3' => {
86
+ # 'row_type' => 'item',
87
+ # 'row_linkedid' => 'catalogue_id_link',
88
+ # 'row_declid' => 'catalogue_declid_link',
89
+ # 'row_name' => 'row_name',
90
+ # 'row_notes' => 'row_notes',
91
+ # 'row_unit' => 'row_unit',
92
+ # 'row_unitAmount' => 'row_unit_amount',
93
+ # 'row_tax' => 'row_taxrate',
94
+ # 'row_taxid' => 'row_taxid',
95
+ # 'row_tax2id' => 'row_tax2id',
96
+ # 'row_qt' => 'row_quantity',
97
+ # 'row_isOption' => 'row_option',
98
+ # 'row_purchaseAmount' => 'row_purchaseAmount',
99
+ # 'row_discount' => 'row_discount',
100
+ # 'row_discountUnit' => 'row_discountUnit'
101
+ # },
102
+ # '4' => {
103
+ # 'row_type' => 'once',
104
+ # 'row_name' => 'row_name',
105
+ # 'row_notes' => 'row_notes',
106
+ # 'row_unit' => 'row_unit',
107
+ # 'row_unitAmount' => 'row_unit_amount',
108
+ # 'row_tax' => 'row_taxrate',
109
+ # 'row_taxid' => 'row_taxid',
110
+ # 'row_tax2id' => 'row_tax2id',
111
+ # 'row_qt' => 'row_quantity',
112
+ # 'row_isOption' => 'row_option',
113
+ # 'row_discount' => 'row_discount',
114
+ # 'row_discountUnit' => 'row_discountUnit'
115
+ # }
116
+ }
117
+ }
118
+ }
119
+
120
+ Sellsy::Api.request command
121
+ end
122
+
123
+ def update
124
+
125
+ end
126
+
127
+ def self.all
128
+ command = {
129
+ 'method' => 'Document.getList',
130
+ 'params' => {
131
+ 'doctype' => 'invoice'
132
+ }
133
+ }
134
+
135
+ response = MultiJson.load(Sellsy::Api.request command)
136
+
137
+ invoices = []
138
+
139
+ response['response']['result'].each do |key, value|
140
+ invoice = Invoice.new
141
+ invoice.id = value['id']
142
+ invoice.corp_name = value['corpname']
143
+ invoice.owner_full_name = value['ownerFullName']
144
+ invoice.status = value['status']
145
+ invoice.identity = value['ident']
146
+ invoice.total_amount_taxes_free = value['totalAmountTaxesFree']
147
+ invoice.taxes_amount_sum = value['taxesAmountSum']
148
+ invoice.total_amount = value['totalAmount']
149
+ invoice.amount = value['rowsAmount']
150
+ invoices << invoice
151
+ end
152
+
153
+ invoices
154
+ end
155
+ end
156
+ end