economic-rest 0.4.3 → 0.4.4
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -3
- data/economic-rest.gemspec +1 -0
- data/lib/economic/base.rb +1 -1
- data/lib/economic/base_repo.rb +39 -23
- data/lib/economic/concerns/soap_methods.rb +36 -2
- data/lib/economic/customer_contact.rb +15 -0
- data/lib/economic/customer_contact_repo.rb +5 -0
- data/lib/economic/invoice.rb +8 -4
- data/lib/economic/invoices/booked_repo.rb +17 -0
- data/lib/economic/invoices/drafts_repo.rb +35 -35
- data/lib/economic/journal_repo.rb +1 -0
- data/lib/economic/nested_base_repo.rb +37 -0
- data/lib/economic/payment_terms_repo.rb +1 -0
- data/lib/economic/product.rb +1 -1
- data/lib/economic/recipient.rb +1 -0
- data/lib/economic/references.rb +2 -0
- data/lib/economic/rest.rb +3 -0
- data/lib/economic/rest/version.rb +1 -1
- data/lib/economic/self_repo.rb +8 -4
- data/lib/economic/session.rb +14 -11
- metadata +21 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecb77f38beb7fd8228abe2b64c507b3ae13da887b8222d7b03c66e336293fca5
|
|
4
|
+
data.tar.gz: 71e58f5128017ecaeb766b866240095f886b4476a240ebc4663c0c38fca649cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf006f406ff0bc9b4bc500d01b0bd0c0092f00fe725a2dca65d64739ccb23e4ceaed0dd2fd5f06454873a29b2aa6a9d67cad4ea86cc22371f9aea907fe7e37ad
|
|
7
|
+
data.tar.gz: 3a9c2e2acbde4319d255bb00038e1b2beb27c637f0e4d9e46d7e5ac61d139c1c1288ebea4ef3d693d951ef1a66edb70a988f8ad5822e87a5f9fa0b74569dc9fb
|
data/Gemfile.lock
CHANGED
|
@@ -39,19 +39,22 @@ GEM
|
|
|
39
39
|
httpi (2.4.4)
|
|
40
40
|
rack
|
|
41
41
|
socksify
|
|
42
|
-
i18n (1.
|
|
42
|
+
i18n (1.7.0)
|
|
43
43
|
concurrent-ruby (~> 1.0)
|
|
44
44
|
jaro_winkler (1.5.3)
|
|
45
45
|
json (2.1.0)
|
|
46
46
|
m (1.5.1)
|
|
47
47
|
method_source (>= 0.6.7)
|
|
48
48
|
rake (>= 0.9.2.2)
|
|
49
|
+
metaclass (0.0.4)
|
|
49
50
|
method_source (0.9.2)
|
|
50
51
|
mime-types (3.3)
|
|
51
52
|
mime-types-data (~> 3.2015)
|
|
52
|
-
mime-types-data (3.2019.
|
|
53
|
+
mime-types-data (3.2019.1009)
|
|
53
54
|
mini_portile2 (2.4.0)
|
|
54
55
|
minitest (5.11.3)
|
|
56
|
+
mocha (1.9.0)
|
|
57
|
+
metaclass (~> 0.0.1)
|
|
55
58
|
netrc (0.11.0)
|
|
56
59
|
nokogiri (1.10.4)
|
|
57
60
|
mini_portile2 (~> 2.4.0)
|
|
@@ -110,7 +113,7 @@ GEM
|
|
|
110
113
|
addressable (>= 2.3.6)
|
|
111
114
|
crack (>= 0.3.2)
|
|
112
115
|
hashdiff
|
|
113
|
-
zeitwerk (2.
|
|
116
|
+
zeitwerk (2.2.0)
|
|
114
117
|
|
|
115
118
|
PLATFORMS
|
|
116
119
|
ruby
|
|
@@ -122,6 +125,7 @@ DEPENDENCIES
|
|
|
122
125
|
economic-rest!
|
|
123
126
|
m
|
|
124
127
|
minitest (~> 5.0)
|
|
128
|
+
mocha
|
|
125
129
|
rake (~> 10.0)
|
|
126
130
|
simplecov
|
|
127
131
|
standard
|
data/economic-rest.gemspec
CHANGED
|
@@ -32,6 +32,7 @@ The documentation can be found at https://restdocs.e-conomic.com'
|
|
|
32
32
|
spec.add_development_dependency "dotenv"
|
|
33
33
|
spec.add_development_dependency "standard"
|
|
34
34
|
spec.add_development_dependency "awesome_print"
|
|
35
|
+
spec.add_development_dependency "mocha"
|
|
35
36
|
|
|
36
37
|
spec.add_dependency "savon"
|
|
37
38
|
spec.add_dependency "rest-client"
|
data/lib/economic/base.rb
CHANGED
|
@@ -48,7 +48,7 @@ module Economic
|
|
|
48
48
|
if relation_hash[:multiple]
|
|
49
49
|
relation_name = relation_hash[:name]
|
|
50
50
|
model_name = relation_hash[:name].singularize
|
|
51
|
-
related_model_array = @internal_hash[relation_name]&.map { |data|
|
|
51
|
+
related_model_array = Array(@internal_hash[relation_name])&.map { |data|
|
|
52
52
|
model_class(model_name).new(data)
|
|
53
53
|
}
|
|
54
54
|
instance_variable_set("@#{relation_name}", related_model_array)
|
data/lib/economic/base_repo.rb
CHANGED
|
@@ -7,24 +7,32 @@ module Economic
|
|
|
7
7
|
URL = "https://restapi.e-conomic.com/".freeze
|
|
8
8
|
|
|
9
9
|
class << self
|
|
10
|
-
|
|
10
|
+
attr_accessor :endpoint
|
|
11
|
+
|
|
12
|
+
def save(model, url: endpoint_url)
|
|
11
13
|
post_or_put = model.id_key.nil? ? :post : :put
|
|
14
|
+
url += "/" + model.id_key.to_s
|
|
15
|
+
|
|
16
|
+
response = send_request(method: post_or_put, url: url, payload: model.to_h.to_json)
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
modelize_response(response)
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
# TODO: This method does not seem to do anything that the save method cannot do - is there any reason to keep it? Posting to a not-existing id is apparenly fine
|
|
22
|
+
def send(model, url: endpoint_url)
|
|
23
|
+
response = send_request(method: :post, url: url, payload: model.to_h.to_json)
|
|
24
|
+
|
|
25
|
+
modelize_response(response)
|
|
18
26
|
end
|
|
19
27
|
|
|
20
|
-
def all(filter_text: "")
|
|
28
|
+
def all(filter_text: "", url: endpoint_url)
|
|
21
29
|
pagination = {}
|
|
22
30
|
pageindex = 0
|
|
23
31
|
entries = []
|
|
24
32
|
|
|
25
33
|
# Loop until last page, last page does not have a 'nextPage'
|
|
26
34
|
while pagination["nextPage"] || pageindex.zero?
|
|
27
|
-
response = fetch(pageindex: pageindex, filter_text: filter_text)
|
|
35
|
+
response = fetch(url: url, pageindex: pageindex, filter_text: filter_text)
|
|
28
36
|
|
|
29
37
|
hash = JSON.parse(response.body)
|
|
30
38
|
hash["collection"].each do |entry_hash|
|
|
@@ -37,16 +45,18 @@ module Economic
|
|
|
37
45
|
entries
|
|
38
46
|
end
|
|
39
47
|
|
|
40
|
-
def filter(filter_text)
|
|
41
|
-
all(filter_text: filter_text)
|
|
48
|
+
def filter(filter_text, url: endpoint_url)
|
|
49
|
+
all(filter_text: filter_text, url: url)
|
|
42
50
|
end
|
|
43
51
|
|
|
44
52
|
def updated_after(date)
|
|
45
53
|
filter("lastUpdated$gt:#{to_iso8601z(date)}")
|
|
46
54
|
end
|
|
47
55
|
|
|
48
|
-
def find(id)
|
|
49
|
-
|
|
56
|
+
def find(id, url: endpoint_url)
|
|
57
|
+
url += "/" + id.to_s
|
|
58
|
+
response = send_request(method: :get, url: url)
|
|
59
|
+
|
|
50
60
|
entry_hash = JSON.parse(response.body)
|
|
51
61
|
model.new(entry_hash)
|
|
52
62
|
end
|
|
@@ -55,14 +65,16 @@ module Economic
|
|
|
55
65
|
URL + endpoint_name
|
|
56
66
|
end
|
|
57
67
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
response = send_request(method: :delete, url: endpoint_url + "/" + id.to_s)
|
|
68
|
+
def destroy(id, url: endpoint_url)
|
|
69
|
+
url += "/" + id.to_s
|
|
70
|
+
response = send_request(method: :delete, url: url)
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
success_codes = [200, 204]
|
|
73
|
+
return true if success_codes.include?(response.code)
|
|
64
74
|
end
|
|
65
75
|
|
|
76
|
+
private
|
|
77
|
+
|
|
66
78
|
def model
|
|
67
79
|
scopes = name.split("::")
|
|
68
80
|
scopes[1] = scopes[1][0...-1] if scopes.count == 3
|
|
@@ -70,6 +82,8 @@ module Economic
|
|
|
70
82
|
end
|
|
71
83
|
|
|
72
84
|
def endpoint_name
|
|
85
|
+
return endpoint unless endpoint.nil?
|
|
86
|
+
|
|
73
87
|
end_p = name.sub("Economic::", "")
|
|
74
88
|
if end_p.include?("::")
|
|
75
89
|
end_p = end_p.gsub("Repo", "")
|
|
@@ -77,11 +91,6 @@ module Economic
|
|
|
77
91
|
else
|
|
78
92
|
end_p = end_p.gsub("Repo", "s")
|
|
79
93
|
end
|
|
80
|
-
end_p = end_p.gsub("Journals", "Journals-Experimental")
|
|
81
|
-
end_p = end_p.gsub("Selfs", "Self")
|
|
82
|
-
# PaymentTerms is named with a plural s for a single record, but the end point is still just paymentterms.
|
|
83
|
-
# Therefore the endpoint gets substituted
|
|
84
|
-
end_p = end_p.gsub("PaymentTermss", "PaymentTerms")
|
|
85
94
|
kebab(end_p)
|
|
86
95
|
end
|
|
87
96
|
|
|
@@ -92,6 +101,7 @@ module Economic
|
|
|
92
101
|
end
|
|
93
102
|
|
|
94
103
|
def send_request(method:, url:, payload: "", &block)
|
|
104
|
+
url = URI.escape(url)
|
|
95
105
|
if payload.strip.empty?
|
|
96
106
|
RestClient::Request.execute(method: method, url: url, headers: headers, &block)
|
|
97
107
|
else
|
|
@@ -105,12 +115,12 @@ module Economic
|
|
|
105
115
|
{'X-AppSecretToken': Session.app_secret_token, 'X-AgreementGrantToken': Session.agreement_grant_token, 'Content-Type': "application/json"}
|
|
106
116
|
end
|
|
107
117
|
|
|
108
|
-
def fetch(pageindex: 0, filter_text: "")
|
|
109
|
-
url =
|
|
118
|
+
def fetch(url: endpoint_url, pageindex: 0, filter_text: "")
|
|
119
|
+
url = url.dup
|
|
110
120
|
url << "?skippages=#{pageindex}&pagesize=1000"
|
|
111
121
|
url << "&filter=#{filter_text}" unless filter_text == ""
|
|
112
122
|
|
|
113
|
-
send_request(method: :get, url:
|
|
123
|
+
send_request(method: :get, url: url)
|
|
114
124
|
end
|
|
115
125
|
|
|
116
126
|
def kebab(string)
|
|
@@ -120,6 +130,12 @@ module Economic
|
|
|
120
130
|
.tr("_", "-")
|
|
121
131
|
.downcase
|
|
122
132
|
end
|
|
133
|
+
|
|
134
|
+
def modelize_response(response)
|
|
135
|
+
entry_hash = response.body.blank? ? {} : JSON.parse(response.body)
|
|
136
|
+
|
|
137
|
+
model.new(entry_hash)
|
|
138
|
+
end
|
|
123
139
|
end
|
|
124
140
|
end
|
|
125
141
|
end
|
|
@@ -34,8 +34,38 @@ module Economic
|
|
|
34
34
|
|
|
35
35
|
result = Economic::SoapAPI.call(
|
|
36
36
|
soap_method_names[:send][:method], message: {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
data: {
|
|
38
|
+
Handle: {
|
|
39
|
+
Id: model.id_key,
|
|
40
|
+
},
|
|
41
|
+
DebtorHandle: {
|
|
42
|
+
Number: model.customer.customer_number,
|
|
43
|
+
},
|
|
44
|
+
DebtorName: model.customer.name,
|
|
45
|
+
Date: to_iso8601z(model.date.to_datetime),
|
|
46
|
+
TermOfPaymentHandle: {
|
|
47
|
+
Id: model.payment_terms.payment_terms_number,
|
|
48
|
+
},
|
|
49
|
+
DueDate: to_iso8601z(model.due_date.to_datetime),
|
|
50
|
+
CurrencyHandle: {
|
|
51
|
+
Code: model.currency,
|
|
52
|
+
},
|
|
53
|
+
ExchangeRate: model.exchange_rate,
|
|
54
|
+
IsVatIncluded: is_vat_included?(model),
|
|
55
|
+
LayoutHandle: {
|
|
56
|
+
Id: model.layout.layout_number,
|
|
57
|
+
},
|
|
58
|
+
DeliveryAddress: model.delivery.address,
|
|
59
|
+
DeliveryPostalCode: model.delivery.zip,
|
|
60
|
+
DeliveryCity: model.delivery.city,
|
|
61
|
+
DeliveryCountry: model.delivery.country,
|
|
62
|
+
DeliveryDate: to_iso8601z(model.delivery.delivery_date.to_datetime),
|
|
63
|
+
Heading: model.notes.heading,
|
|
64
|
+
NetAmount: model.net_amount,
|
|
65
|
+
VatAmount: model.vat_amount,
|
|
66
|
+
GrossAmount: model.gross_amount,
|
|
67
|
+
Margin: model.margin_in_base_currency,
|
|
68
|
+
MarginAsPercent: model.margin_percentage,
|
|
39
69
|
},
|
|
40
70
|
}
|
|
41
71
|
)
|
|
@@ -178,6 +208,10 @@ module Economic
|
|
|
178
208
|
|
|
179
209
|
arr
|
|
180
210
|
end
|
|
211
|
+
|
|
212
|
+
def is_vat_included?(model)
|
|
213
|
+
model.vat_amount != 0
|
|
214
|
+
end
|
|
181
215
|
end
|
|
182
216
|
end
|
|
183
217
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Economic
|
|
2
|
+
class CustomerContact < Base
|
|
3
|
+
field :customerContactNumber, id: true
|
|
4
|
+
field :deleted
|
|
5
|
+
field :eInvoiceId
|
|
6
|
+
field :email
|
|
7
|
+
# field :emailNotifications - is an array
|
|
8
|
+
field :name
|
|
9
|
+
field :notes
|
|
10
|
+
field :phone
|
|
11
|
+
field :sortKey
|
|
12
|
+
|
|
13
|
+
relation :customer, fields: [:customerNumber]
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/economic/invoice.rb
CHANGED
|
@@ -13,20 +13,23 @@ module Economic
|
|
|
13
13
|
field :roundingAmount
|
|
14
14
|
field :vatAmount
|
|
15
15
|
field :draftInvoiceNumber, id: true # This changes name depending on its type (draft, unpaid etc)
|
|
16
|
+
field :bookedInvoiceNumber
|
|
17
|
+
field :remainder
|
|
16
18
|
|
|
17
19
|
relation :customer, fields: [:customerNumber]
|
|
18
|
-
|
|
20
|
+
relation :delivery, fields: []
|
|
19
21
|
# relation :deliveryLocation, fields: []
|
|
20
22
|
relation :layout, fields: [:layoutNumber]
|
|
21
|
-
|
|
23
|
+
relation :notes, fields: []
|
|
22
24
|
relation :paymentTerms, fields: [:paymentTermsNumber]
|
|
23
25
|
# relation :pdf, fields: []
|
|
24
26
|
# relation :project, fields: []
|
|
25
|
-
relation :recipient, fields: [:name]
|
|
27
|
+
relation :recipient, fields: [:name, :ean]
|
|
26
28
|
relation :references, fields: [:other]
|
|
27
|
-
relation :lines, fields: [:lineNumber], multiple: true
|
|
29
|
+
relation :lines, fields: [:lineNumber, :description, :sortKey, :quantity, :unitNetPrice, :discountPercentage, :unitCostPrice, :marginInBaseCurrency, :marginPercentage, :totalNetAmount], multiple: true
|
|
28
30
|
|
|
29
31
|
def self.build_from_soap_api(data)
|
|
32
|
+
# TODO: Add all the options
|
|
30
33
|
hash = {
|
|
31
34
|
"currency" => data[:currency_handle][:code],
|
|
32
35
|
"date" => data[:date].to_date,
|
|
@@ -44,6 +47,7 @@ module Economic
|
|
|
44
47
|
"customer" => {"customerNumber" => data[:debtor_handle][:id].to_i},
|
|
45
48
|
"layout" => {"layoutNumber" => data[:layout_handle][:id].to_i},
|
|
46
49
|
"paymentTerms" => {"paymentTermsNumber" => data[:term_of_payment_handle][:id].to_i},
|
|
50
|
+
"references" => {"other" => data[:other_reference]},
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
new(hash)
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
module Economic
|
|
2
2
|
module Invoices
|
|
3
3
|
class BookedRepo < Economic::Invoices::Repo
|
|
4
|
+
class << self
|
|
5
|
+
def send(invoice)
|
|
6
|
+
response = send_request(method: :post, url: URI.escape(endpoint_url), payload: payload(invoice))
|
|
7
|
+
|
|
8
|
+
entry_hash = JSON.parse(response.body)
|
|
9
|
+
|
|
10
|
+
invoice.class.new(entry_hash)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def payload(invoice)
|
|
16
|
+
{
|
|
17
|
+
draftInvoice: invoice.to_h,
|
|
18
|
+
}.to_json
|
|
19
|
+
end
|
|
20
|
+
end
|
|
4
21
|
end
|
|
5
22
|
end
|
|
6
23
|
end
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
module Economic
|
|
2
2
|
module Invoices
|
|
3
3
|
class DraftsRepo < Economic::Invoices::Repo
|
|
4
|
-
include Economic::SoapMethods
|
|
4
|
+
# include Economic::SoapMethods
|
|
5
5
|
|
|
6
|
-
class << self
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
6
|
+
# class << self
|
|
7
|
+
# def soap_method_names
|
|
8
|
+
# {
|
|
9
|
+
# find: {method: :current_invoice_get_data, handle: :entityHandle},
|
|
10
|
+
# all: {method: :current_invoice_get_all, handle: :current_invoice_handle},
|
|
11
|
+
# send: {method: :current_invoice_create_from_data},
|
|
12
|
+
# find_lines: {
|
|
13
|
+
# method: :current_invoice_get_lines,
|
|
14
|
+
# handle: :currentInvoiceHandle,
|
|
15
|
+
# line_handle: :current_invoice_line_handle,
|
|
16
|
+
# },
|
|
17
|
+
# create_lines: {
|
|
18
|
+
# method: :current_invoice_line_create_from_data_array,
|
|
19
|
+
# line_data_handle: :CurrentInvoiceLineData,
|
|
20
|
+
# model_handle: :InvoiceHandle,
|
|
21
|
+
# },
|
|
22
|
+
# find_all_lines: {
|
|
23
|
+
# method: :current_invoice_line_get_data_array,
|
|
24
|
+
# handle: :entityHandles,
|
|
25
|
+
# data: :current_invoice_line_data,
|
|
26
|
+
# line_handle: :CurrentInvoiceLineHandle,
|
|
27
|
+
# },
|
|
28
|
+
# find_all_records: {
|
|
29
|
+
# method: :current_invoice_get_data_array,
|
|
30
|
+
# handle: :CurrentInvoiceHandle,
|
|
31
|
+
# data: :current_invoice_data,
|
|
32
|
+
# },
|
|
33
|
+
# destroy: {
|
|
34
|
+
# method: :current_invoice_delete,
|
|
35
|
+
# handle: :currentInvoiceHandle,
|
|
36
|
+
# },
|
|
37
|
+
# }
|
|
38
|
+
# end
|
|
39
|
+
# end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Economic
|
|
2
|
+
class NestedBaseRepo < Economic::BaseRepo
|
|
3
|
+
class << self
|
|
4
|
+
def all(filter_text: "", on:)
|
|
5
|
+
super(filter_text: filter_text, url: nested_endpoint_url(on))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def filter(filter_text, on:)
|
|
9
|
+
all(filter_text: filter_text, on: on)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def nested_endpoint_url(model)
|
|
13
|
+
Economic::BaseRepo::URL + nested_endpoint_name(model)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def nested_endpoint_name(model)
|
|
17
|
+
"#{kebab(model.class.name.demodulize.pluralize)}/#{model.id_key}/#{endpoint_name}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def send(model, on:)
|
|
21
|
+
super(model, url: nested_endpoint_url(on))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def save(model, on:)
|
|
25
|
+
super(model, url: nested_endpoint_url(on))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def find(id, on:)
|
|
29
|
+
super(id, url: nested_endpoint_url(on))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def destroy(id, on:)
|
|
33
|
+
super(id, url: nested_endpoint_url(on))
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/economic/product.rb
CHANGED
data/lib/economic/recipient.rb
CHANGED
data/lib/economic/references.rb
CHANGED
data/lib/economic/rest.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "savon"
|
|
|
5
5
|
require "active_support/inflector"
|
|
6
6
|
|
|
7
7
|
require "economic/base_repo"
|
|
8
|
+
require "economic/nested_base_repo"
|
|
8
9
|
require "economic/base"
|
|
9
10
|
require "economic/soap_api"
|
|
10
11
|
require "economic/concerns/soap_methods"
|
|
@@ -33,6 +34,8 @@ require "economic/references"
|
|
|
33
34
|
require "economic/customer_repo"
|
|
34
35
|
require "economic/customer"
|
|
35
36
|
require "economic/customer_group_repo"
|
|
37
|
+
require "economic/customer_contact"
|
|
38
|
+
require "economic/customer_contact_repo"
|
|
36
39
|
require "economic/product_repo"
|
|
37
40
|
require "economic/product"
|
|
38
41
|
require "economic/pricing_repo"
|
data/lib/economic/self_repo.rb
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
module Economic
|
|
2
2
|
class SelfRepo < Economic::BaseRepo
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
self.endpoint = "self"
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
def self
|
|
7
|
+
response = send_request(method: :get, url: URI.escape(Economic::SelfRepo.endpoint_url))
|
|
8
|
+
entry_hash = JSON.parse(response.body)
|
|
9
|
+
model.new(entry_hash)
|
|
10
|
+
end
|
|
7
11
|
end
|
|
8
12
|
end
|
|
9
13
|
end
|
data/lib/economic/session.rb
CHANGED
|
@@ -2,21 +2,24 @@ module Economic
|
|
|
2
2
|
# The Economic::Session contains details and behaviors for a current
|
|
3
3
|
# connection to the API endpoint.
|
|
4
4
|
class Session
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
class << self
|
|
6
|
+
def authentication(private_app_id, access_id)
|
|
7
|
+
@private_app_id = private_app_id
|
|
8
|
+
@access_id = access_id
|
|
9
|
+
end
|
|
10
|
+
alias authenticate authentication
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
def app_secret_token
|
|
13
|
+
raise ArgumentError, "Authentication tokens not set, Call Session.authentication" if @private_app_id.nil?
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
@private_app_id
|
|
16
|
+
end
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
def agreement_grant_token
|
|
19
|
+
raise ArgumentError, "Authentication tokens not set, Call Session.authentication" if @access_id.nil?
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
@access_id
|
|
22
|
+
end
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: economic-rest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Klogborg
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-10-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -136,6 +136,20 @@ dependencies:
|
|
|
136
136
|
- - ">="
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: mocha
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
139
153
|
- !ruby/object:Gem::Dependency
|
|
140
154
|
name: savon
|
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -204,6 +218,8 @@ files:
|
|
|
204
218
|
- lib/economic/concerns/soap_methods.rb
|
|
205
219
|
- lib/economic/currency.rb
|
|
206
220
|
- lib/economic/customer.rb
|
|
221
|
+
- lib/economic/customer_contact.rb
|
|
222
|
+
- lib/economic/customer_contact_repo.rb
|
|
207
223
|
- lib/economic/customer_group.rb
|
|
208
224
|
- lib/economic/customer_group_repo.rb
|
|
209
225
|
- lib/economic/customer_repo.rb
|
|
@@ -224,6 +240,7 @@ files:
|
|
|
224
240
|
- lib/economic/layout.rb
|
|
225
241
|
- lib/economic/layout_repo.rb
|
|
226
242
|
- lib/economic/line.rb
|
|
243
|
+
- lib/economic/nested_base_repo.rb
|
|
227
244
|
- lib/economic/notes.rb
|
|
228
245
|
- lib/economic/order.rb
|
|
229
246
|
- lib/economic/orders/archived_repo.rb
|
|
@@ -275,7 +292,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
275
292
|
- !ruby/object:Gem::Version
|
|
276
293
|
version: '0'
|
|
277
294
|
requirements: []
|
|
278
|
-
|
|
295
|
+
rubyforge_project:
|
|
296
|
+
rubygems_version: 2.7.6
|
|
279
297
|
signing_key:
|
|
280
298
|
specification_version: 4
|
|
281
299
|
summary: Ruby wrapper for the e-conomic REST API, that aims at making working with
|