elmas 0.1.2 → 0.2.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/LICENSE +21 -0
- data/README.md +94 -12
- data/elmas.gemspec +2 -1
- data/lib/elmas.rb +23 -2
- data/lib/elmas/config.rb +1 -1
- data/lib/elmas/log.rb +2 -0
- data/lib/elmas/oauth.rb +14 -0
- data/lib/elmas/parser.rb +17 -1
- data/lib/elmas/resource.rb +13 -18
- data/lib/elmas/resources/account.rb +1 -1
- data/lib/elmas/resources/bank_entry.rb +20 -0
- data/lib/elmas/resources/bank_entry_line.rb +18 -0
- data/lib/elmas/resources/base_entry_line.rb +16 -0
- data/lib/elmas/resources/contact.rb +8 -1
- data/lib/elmas/resources/costcenter.rb +17 -0
- data/lib/elmas/resources/costunit.rb +17 -0
- data/lib/elmas/resources/document.rb +21 -0
- data/lib/elmas/resources/document_attachment.rb +17 -0
- data/lib/elmas/resources/gl_account.rb +25 -0
- data/lib/elmas/resources/item.rb +20 -4
- data/lib/elmas/resources/item_group.rb +21 -0
- data/lib/elmas/resources/journal.rb +5 -1
- data/lib/elmas/resources/mailbox.rb +20 -0
- data/lib/elmas/resources/purchase_entry.rb +21 -0
- data/lib/elmas/resources/purchase_entry_line.rb +9 -0
- data/lib/elmas/resources/sales_entry.rb +24 -0
- data/lib/elmas/resources/sales_entry_line.rb +10 -0
- data/lib/elmas/resources/sales_invoice.rb +26 -0
- data/lib/elmas/resources/sales_invoice_line.rb +25 -0
- data/lib/elmas/resources/sales_order.rb +24 -0
- data/lib/elmas/resources/sales_order_line.rb +24 -0
- data/lib/elmas/resources/shared_sales_attributes.rb +16 -0
- data/lib/elmas/resources/transaction.rb +21 -0
- data/lib/elmas/resources/transaction_line.rb +21 -0
- data/lib/elmas/resources/vat_code.rb +23 -0
- data/lib/elmas/response.rb +23 -5
- data/lib/elmas/sanitizer.rb +48 -0
- data/lib/elmas/uri.rb +5 -1
- data/lib/elmas/utils.rb +1 -1
- data/lib/elmas/version.rb +2 -2
- metadata +44 -8
- data/lib/elmas/resources/invoice.rb +0 -19
- data/lib/elmas/resources/invoice_line.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb71ef967c15aeffc592ac76915b0f31078877f1
|
4
|
+
data.tar.gz: 1ef5c1c7611901311cd897933d8deb26748e8239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d9b9152c771283da77515702a6976d991027041a48ac2e92a8857a37003b95b057d3fa31bda66ba898f388c87d59fb2f1736c3ed7a5464f03bc26244d3aed2f
|
7
|
+
data.tar.gz: 24f03387316472d659d09c34482ee728535a665af923ff3eee4ca71a847310e6d63c121cd3548784a80358cc5824e44d1d459d5579ad82a687bdba3d76a58b88
|
data/.travis.yml
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) [2015] [Hoppinger]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
[![Code Climate](https://codeclimate.com/github/exactonline/exactonline-api-ruby-client/badges/gpa.svg)](https://codeclimate.com/github/exactonline/exactonline-api-ruby-client)
|
3
|
-
[![Version](https://
|
1
|
+
[![Build Status](https://travis-ci.org/exactonline/exactonline-api-ruby-client.svg?branch=master)](https://travis-ci.org/exactonline/exactonline-api-ruby-client)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/exactonline/exactonline-api-ruby-client/badges/gpa.svg)](https://codeclimate.com/github/exactonline/exactonline-api-ruby-client)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/elmas.svg)](http://badge.fury.io/rb/elmas)
|
4
4
|
|
5
5
|
# Elmas
|
6
6
|
|
@@ -22,12 +22,11 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install elmas
|
24
24
|
|
25
|
-
##
|
25
|
+
## Authorization and Setup
|
26
26
|
|
27
27
|
You have to have an Exact Online account and an app setup to connect with.
|
28
28
|
|
29
|
-
You have to set a few variables to make a connection possible. I'd suggest using environment variables set with [dotenv](https://github.com/bkeepers/dotenv) for that.
|
30
|
-
|
29
|
+
You have to set a few variables to make a connection possible. I'd suggest using environment variables set with [dotenv](https://github.com/bkeepers/dotenv) for that.
|
31
30
|
|
32
31
|
Then configure Elmas like this
|
33
32
|
|
@@ -35,9 +34,44 @@ Then configure Elmas like this
|
|
35
34
|
Elmas.configure do |config|
|
36
35
|
config.client_id = ENV['CLIENT_ID']
|
37
36
|
config.client_secret = ENV['CLIENT_SECRET']
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
If you only use the api within your app without exposing it to users you can chose
|
41
|
+
to automatically login with your credentials. So this is for example when you have a
|
42
|
+
rake task that shoots in invoices.
|
43
|
+
Do not use this when you let other users login. Build your own OAUTH flow and then set the access token
|
44
|
+
before the api request.
|
45
|
+
```ruby
|
46
|
+
Elmas.configure do |config|
|
38
47
|
config.access_token = Elmas.authorize(ENV['EXACT_USER_NAME'], ENV['EXACT_PASSWORD']).access_token
|
39
48
|
end
|
49
|
+
```
|
50
|
+
Now you're authorized you can set your current division
|
51
|
+
```ruby
|
52
|
+
Elmas.configure do |config|
|
53
|
+
config.division = Elmas.authorize_division
|
54
|
+
end
|
55
|
+
```
|
40
56
|
|
57
|
+
So combining all of this results in
|
58
|
+
```ruby
|
59
|
+
Elmas.configure do |config|
|
60
|
+
config.client_id = ENV['CLIENT_ID']
|
61
|
+
config.client_secret = ENV['CLIENT_SECRET']
|
62
|
+
end
|
63
|
+
Elmas.configure do |config|
|
64
|
+
config.access_token = Elmas.authorize(ENV['EXACT_USER_NAME'], ENV['EXACT_PASSWORD']).access_token
|
65
|
+
end
|
66
|
+
Elmas.configure do |config|
|
67
|
+
config.division = Elmas.authorize_division
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
You should make sure that when you do a request you're authorized. So build in something like the
|
72
|
+
following code into your application, that checks wether you're authorized and otherwise authorizes
|
73
|
+
again.
|
74
|
+
```ruby
|
41
75
|
#The client will now be authorized for 10 minutes,
|
42
76
|
# if there are requests the time will be reset,
|
43
77
|
# otherwise authorization should be called again.
|
@@ -48,12 +82,29 @@ unless Elmas.authorized?
|
|
48
82
|
end
|
49
83
|
```
|
50
84
|
|
85
|
+
## GET, PUT, POST requests
|
86
|
+
|
87
|
+
For any of the following requests (GET, PUT, POST), to get the results do the following. (the exact API always returns a List)
|
88
|
+
```ruby
|
89
|
+
contact = Elmas::Contact.new(id: "23445")
|
90
|
+
response = contact.find
|
91
|
+
puts response.first
|
92
|
+
# Prints something like this
|
93
|
+
# [<Elmas::Contact:0x007fb0a55782f0 @attributes={:__metadata=>{"uri"=>"https://start.exactonline.nl/api/v1/797636/crm/Contacts(guid'23445')", "type"=>"Exact.Web.Api.Models.Contact"}, :id=>"23445", :person=>"88380fa4-97bc-4ddf-90e3-b0e7befb112c"}>
|
94
|
+
|
95
|
+
contact = Elmas::Contact.new.find_all
|
96
|
+
response = contact.find_all
|
97
|
+
puts response.results
|
98
|
+
# Prints something like this
|
99
|
+
# [<Elmas::Contact:0x007fb0a55782f0 @attributes={:__metadata=>{"uri"=>"https://start.exactonline.nl/api/v1/797636/crm/Contacts(guid'23445')", "type"=>"Exact.Web.Api.Models.Contact"}, :id=>"23445", :person=>"88380fa4-97bc-4ddf-90e3-b0e7befb112c"}>, <Elmas::Contact:0x007fb0a55782f0 @attributes={:__metadata=>{"uri"=>"https://start.exactonline.nl/api/v1/797636/crm/Contacts(guid'23445')", "type"=>"Exact.Web.Api.Models.Contact"}, :id=>"23445", :person=>"88380fa4-97bc-4ddf-90e3-b0e7befb112c"}>]
|
100
|
+
```
|
101
|
+
|
51
102
|
To find a contact
|
52
103
|
|
53
104
|
```ruby
|
54
105
|
contact = Elmas::Contact.new(id: "23445")
|
55
106
|
contact.find
|
56
|
-
# path = /crm/Contacts
|
107
|
+
# path = /crm/Contacts(guid'23445')
|
57
108
|
```
|
58
109
|
|
59
110
|
To find a contact with specific filters
|
@@ -73,8 +124,8 @@ contact.find_by(filters: [:first_name], order_by: :first_name)
|
|
73
124
|
To find contacts with an order, a filter and selecting relationships
|
74
125
|
```ruby
|
75
126
|
contact = Elmas::Contact.new(first_name: "Karel")
|
76
|
-
contact.find_by(filters: [:first_name], order_by: :first_name, select: [:
|
77
|
-
# path = /crm/Contacts?$select=
|
127
|
+
contact.find_by(filters: [:first_name], order_by: :first_name, select: [:last_name])
|
128
|
+
# path = /crm/Contacts?$select=last_name&$order_by=first_name&$filter=first_name eq 'Karel'
|
78
129
|
```
|
79
130
|
|
80
131
|
So with find_by you can combine Filters, Select and OrderBy. For more information on this way of selecting data look here http://www.odata.org/
|
@@ -97,17 +148,48 @@ contact.find_all(order_by: :first_name)
|
|
97
148
|
To find all contacts and select invoices and items
|
98
149
|
```ruby
|
99
150
|
contact = Elmas::Contact.new
|
100
|
-
contact.find_all(select: [:
|
101
|
-
# path = /crm/Contacts?$select=
|
151
|
+
contact.find_all(select: [:last_name, :first_name])
|
152
|
+
# path = /crm/Contacts?$select=last_name,first_name
|
102
153
|
```
|
103
154
|
|
104
155
|
To create a new contact
|
105
156
|
|
106
157
|
```ruby
|
107
|
-
contact = Elmas::Contact.new(first_name: "Karel", last_name: "Appel"
|
158
|
+
contact = Elmas::Contact.new(first_name: "Karel", last_name: "Appel" )
|
108
159
|
contact.save
|
109
160
|
```
|
110
161
|
|
162
|
+
### SalesInvoice flow
|
163
|
+
SalesInvoices have a relationship with SalesInvoiceLines. A SalesInvoice has many
|
164
|
+
SalesInvoiceLines and a SalesInvoiceLine belongs to a SalesInvoice. To create a
|
165
|
+
valid SalesInvoice you need to embed the SalesInvoiceLines
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
sales_invoice = Elmas::SalesInvoice.new(journal: "id of your journal", ordered_by: "id of customer")
|
169
|
+
```
|
170
|
+
Now it still needs SalesInvoiceLines
|
171
|
+
```ruby
|
172
|
+
sales_invoice_lines = []
|
173
|
+
sales_invoice_lines << Elmas::SalesInvoiceLine.new(item: "id of item being sold") # do this for each item you want in the invoice.
|
174
|
+
sales_invoice.sales_invoice_lines = sales_invoice_lines
|
175
|
+
```
|
176
|
+
Now you can save the SalesInvoice and it will be parsed to the following
|
177
|
+
```ruby
|
178
|
+
sales_invoice.save
|
179
|
+
# Sanitized object: {"Journal"=>"id of your journal", "OrderedBy"=>"id of customer", "SalesInvoiceLines"=>[{"Item"=>"id of item being sold"}]}
|
180
|
+
```
|
181
|
+
|
182
|
+
If you have a SalesInvoice with an id(so saved before already), you can also create invoice lines without embedding
|
183
|
+
```ruby
|
184
|
+
sales_invoice = Elmas::SalesInvoice.new({id: "1"}).first
|
185
|
+
sales_invoice_line = Elmas::SalesInvoiceLine.new(invoice_ID: sales_invoice, item: "42")
|
186
|
+
sales_invoice.save
|
187
|
+
# Sanitized object: {"Item"=>"42", "InvoiceID"=>"1"}
|
188
|
+
```
|
189
|
+
|
190
|
+
For many resources there are mandatory attributes, you can see that in the classes
|
191
|
+
for every resource. For example for Contact: https://github.com/exactonline/exactonline-api-ruby-client/blob/master/lib/elmas/resources/contact.rb
|
192
|
+
|
111
193
|
###Divisions and Endpoints
|
112
194
|
|
113
195
|
Usually in the exact wrapper you need a division number, this one will be set on authorization checks (with `/Current/Me` endpoint). Sometimes you need to do a request without the division number, or even without the standard `/api/v1` endpoint. Like so:
|
data/elmas.gemspec
CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.add_dependency "faraday", [">= 0.8", "< 0.10"]
|
20
20
|
spec.add_dependency "mechanize", "2.6.0"
|
21
|
+
spec.add_dependency "activesupport"
|
21
22
|
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "bundler"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
25
|
spec.add_development_dependency("rspec", "~> 3.0")
|
25
26
|
spec.add_development_dependency("simplecov")
|
data/lib/elmas.rb
CHANGED
@@ -5,12 +5,33 @@ require "elmas/response"
|
|
5
5
|
require "elmas/client"
|
6
6
|
require "elmas/log"
|
7
7
|
require "elmas/resource"
|
8
|
+
require "elmas/sanitizer"
|
9
|
+
require "elmas/resources/shared_sales_attributes"
|
10
|
+
require "elmas/resources/base_entry_line"
|
11
|
+
require "elmas/resources/bank_entry"
|
12
|
+
require "elmas/resources/bank_entry_line"
|
8
13
|
require "elmas/resources/contact"
|
9
|
-
require "elmas/resources/
|
14
|
+
require "elmas/resources/sales_invoice"
|
10
15
|
require "elmas/resources/journal"
|
11
16
|
require "elmas/resources/item"
|
12
|
-
require "elmas/resources/
|
17
|
+
require "elmas/resources/item_group"
|
18
|
+
require "elmas/resources/sales_invoice_line"
|
13
19
|
require "elmas/resources/account"
|
20
|
+
require "elmas/resources/gl_account"
|
21
|
+
require "elmas/resources/sales_entry"
|
22
|
+
require "elmas/resources/sales_entry_line"
|
23
|
+
require "elmas/resources/sales_order"
|
24
|
+
require "elmas/resources/sales_order_line"
|
25
|
+
require "elmas/resources/purchase_entry"
|
26
|
+
require "elmas/resources/purchase_entry_line"
|
27
|
+
require "elmas/resources/costunit"
|
28
|
+
require "elmas/resources/costcenter"
|
29
|
+
require "elmas/resources/transaction"
|
30
|
+
require "elmas/resources/transaction_line"
|
31
|
+
require "elmas/resources/document"
|
32
|
+
require "elmas/resources/document_attachment"
|
33
|
+
require "elmas/resources/mailbox"
|
34
|
+
require "elmas/resources/vat_code"
|
14
35
|
|
15
36
|
module Elmas
|
16
37
|
extend Config
|
data/lib/elmas/config.rb
CHANGED
data/lib/elmas/log.rb
CHANGED
data/lib/elmas/oauth.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "mechanize"
|
2
2
|
require "uri"
|
3
|
+
require "json"
|
3
4
|
|
4
5
|
require File.expand_path("../utils", __FILE__)
|
5
6
|
require File.expand_path("../response", __FILE__)
|
@@ -27,6 +28,19 @@ module Elmas
|
|
27
28
|
get("/Current/Me", no_division: true).first.current_division
|
28
29
|
end
|
29
30
|
|
31
|
+
def auto_authorize
|
32
|
+
Elmas.configure do |config|
|
33
|
+
config.client_id = ENV["CLIENT_ID"]
|
34
|
+
config.client_secret = ENV["CLIENT_SECRET"]
|
35
|
+
end
|
36
|
+
Elmas.configure do |config|
|
37
|
+
config.access_token = Elmas.authorize(ENV["EXACT_USER_NAME"], ENV["EXACT_PASSWORD"]).access_token
|
38
|
+
end
|
39
|
+
Elmas.configure do |config|
|
40
|
+
config.division = Elmas.authorize_division
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
30
44
|
# Return URL for OAuth authorization
|
31
45
|
def authorize_url(options = {})
|
32
46
|
options[:response_type] ||= "code"
|
data/lib/elmas/parser.rb
CHANGED
@@ -2,10 +2,26 @@ module Elmas
|
|
2
2
|
class Parser
|
3
3
|
def initialize(json)
|
4
4
|
@object = JSON.parse(json)
|
5
|
+
rescue JSON::ParserError => e
|
6
|
+
Elmas.error("There was an error parsing the response, #{e.message}")
|
7
|
+
@error_message = e.message
|
8
|
+
return false
|
5
9
|
end
|
6
10
|
|
7
11
|
def results
|
8
|
-
@object["d"]["results"]
|
12
|
+
@object["d"]["results"] if @object
|
13
|
+
end
|
14
|
+
|
15
|
+
def metadata
|
16
|
+
@object["d"]["__metadata"] if @object
|
17
|
+
end
|
18
|
+
|
19
|
+
def result
|
20
|
+
@object["d"] if @object
|
21
|
+
end
|
22
|
+
|
23
|
+
def error_message
|
24
|
+
@error_message ||= @object["error"]["message"]["value"]
|
9
25
|
end
|
10
26
|
|
11
27
|
def first_result
|
data/lib/elmas/resource.rb
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
require File.expand_path("../utils", __FILE__)
|
2
2
|
require File.expand_path("../exception", __FILE__)
|
3
3
|
require File.expand_path("../uri", __FILE__)
|
4
|
+
require File.expand_path("../sanitizer", __FILE__)
|
4
5
|
|
5
6
|
module Elmas
|
6
7
|
module Resource
|
7
8
|
include UriMethods
|
8
|
-
|
9
|
-
STANDARD_FILTERS = [:id].freeze
|
9
|
+
include Sanitizer
|
10
10
|
|
11
11
|
attr_accessor :attributes, :url
|
12
12
|
attr_reader :response
|
13
13
|
|
14
14
|
def initialize(attributes = {})
|
15
15
|
@attributes = Utils.normalize_hash(attributes)
|
16
|
-
@filters =
|
16
|
+
@filters = []
|
17
17
|
@query = []
|
18
18
|
end
|
19
19
|
|
20
|
+
def id
|
21
|
+
@attributes[:id]
|
22
|
+
end
|
23
|
+
|
20
24
|
def find_all(options = {})
|
21
25
|
@order_by = options[:order_by]
|
22
26
|
@select = options[:select]
|
23
|
-
get(uri([:order, :select]))
|
27
|
+
response = get(uri([:order, :select]))
|
28
|
+
response.results if response
|
24
29
|
end
|
25
30
|
|
26
31
|
# Pass filters in an array, for example 'filters: [:id, :name]'
|
@@ -28,12 +33,14 @@ module Elmas
|
|
28
33
|
@filters = options[:filters]
|
29
34
|
@order_by = options[:order_by]
|
30
35
|
@select = options[:select]
|
31
|
-
get(uri([:order, :select, :filters]))
|
36
|
+
response = get(uri([:order, :select, :filters]))
|
37
|
+
response.results if response
|
32
38
|
end
|
33
39
|
|
34
40
|
def find
|
35
41
|
return nil unless id?
|
36
|
-
get(uri([:
|
42
|
+
response = get(uri([:id]))
|
43
|
+
response.result if response
|
37
44
|
end
|
38
45
|
|
39
46
|
# Normally use the url method (which applies the filters) but sometimes you only want to use the base path or other paths
|
@@ -72,18 +79,6 @@ module Elmas
|
|
72
79
|
Elmas.delete(basic_identifier_uri)
|
73
80
|
end
|
74
81
|
|
75
|
-
# Parse the attributes for to post to the API
|
76
|
-
def sanitize
|
77
|
-
to_submit = {}
|
78
|
-
@attributes.each do |key, value|
|
79
|
-
next if key == :id || !valid_attribute?(key)
|
80
|
-
key = Utils.parse_key(key)
|
81
|
-
value.is_a?(Elmas::Resource) ? submit_value = value.id : submit_value = value # Turn relation into ID
|
82
|
-
to_submit[key] = submit_value
|
83
|
-
end
|
84
|
-
to_submit
|
85
|
-
end
|
86
|
-
|
87
82
|
# Getter/Setter for resource
|
88
83
|
def method_missing(method, *args, &block)
|
89
84
|
yield if block
|
@@ -30,7 +30,7 @@ module Elmas
|
|
30
30
|
:payment_condition_purchase, :payment_condition_sales, :phone,
|
31
31
|
:phone_extension, :postcode, :price_list, :purchase_currency,
|
32
32
|
:purchase_lead_days, :purchase_VAT_code, :recipient_of_commissions,
|
33
|
-
:remarks, :reseller, :sales_currency, :sales_tax_schedule, :
|
33
|
+
:remarks, :reseller, :sales_currency, :sales_tax_schedule, :sales_VAT_code,
|
34
34
|
:search_code, :security_level, :seperate_inv_per_project, :seperate_inv_per_subscription,
|
35
35
|
:shipping_lead_days, :shipping_method, :start_date, :state, :status,
|
36
36
|
:VAT_liability, :VAT_number, :website
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Elmas
|
2
|
+
class BankEntry
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"financialtransaction/BankEntries"
|
7
|
+
end
|
8
|
+
|
9
|
+
def mandatory_attributes
|
10
|
+
[:journal_code, :bank_entry_lines]
|
11
|
+
end
|
12
|
+
|
13
|
+
def other_attributes
|
14
|
+
[
|
15
|
+
:currency, :bank_statement_document, :closing_balance_FC, :entry_number,
|
16
|
+
:financial_period, :financial_year, :openening_balance_FC
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Elmas
|
2
|
+
class BankEntryLine < Elmas::BaseEntryLine
|
3
|
+
# A sales entry line belongs to a sales entry
|
4
|
+
include Elmas::Resource
|
5
|
+
|
6
|
+
def base_path
|
7
|
+
"financialtransaction/BankEntryLines"
|
8
|
+
end
|
9
|
+
|
10
|
+
def other_attributes
|
11
|
+
[
|
12
|
+
:account, :amount_VATFC, :asset, :cost_center, :cost_unit, :date,
|
13
|
+
:description, :notes, :document, :exchange_rate, :our_ref,
|
14
|
+
:project, :quantity, :VAT_code, :VAT_percentage, :VAT_type
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Elmas
|
2
|
+
class BaseEntryLine
|
3
|
+
def mandatory_attributes
|
4
|
+
[:amount_FC, :GL_account, :entry_ID]
|
5
|
+
end
|
6
|
+
|
7
|
+
def other_attributes
|
8
|
+
[
|
9
|
+
:serial_number, :asset, :cost_center, :cost_unit, :description, :notes,
|
10
|
+
:project, :quantity, :serial_number, :subscription, :tracking_number,
|
11
|
+
:VAT_amount_FC, :VAT_base_amount_DC, :VAT_base_amount_FC, :VAT_code,
|
12
|
+
:VAT_percentage
|
13
|
+
]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -12,7 +12,14 @@ module Elmas
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def other_attributes
|
15
|
-
[
|
15
|
+
[
|
16
|
+
:account_name, :birt_date, :birth_name, :birth_name_prefix, :birth_place,
|
17
|
+
:business_email, :business_fax, :business_mobile, :business_phone, :business_phone_extention,
|
18
|
+
:email, :end_date, :first_name, :gender, :HID, :initials, :is_mailing_excluded,
|
19
|
+
:job_title_description, :language, :marketing_notes, :middle_name,
|
20
|
+
:mobile, :nationality, :notes, :person, :phone, :picture, :picture_name,
|
21
|
+
:social_security_number, :start_date, :title
|
22
|
+
]
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Elmas
|
2
|
+
class Document
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"documents/Documents"
|
7
|
+
end
|
8
|
+
|
9
|
+
def mandatory_attributes
|
10
|
+
[:subject, :type]
|
11
|
+
end
|
12
|
+
|
13
|
+
def other_attributes
|
14
|
+
[
|
15
|
+
:account, :amount_FC, :body, :category, :category_description, :creator_full_name,
|
16
|
+
:currency, :document_date, :document_folder, :financial_transaction_entry_ID,
|
17
|
+
:HID, :language, :opportunity, :sales_invoice_number, :shop_order_number
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Elmas
|
2
|
+
class DocumentAttachment
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"documents/DocumentAttachments"
|
7
|
+
end
|
8
|
+
|
9
|
+
def mandatory_attributes
|
10
|
+
[:attachment, :document, :file_name]
|
11
|
+
end
|
12
|
+
|
13
|
+
def other_attributes
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Elmas
|
2
|
+
class GLAccount
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"financial/GLAccounts"
|
7
|
+
end
|
8
|
+
|
9
|
+
def mandatory_attributes
|
10
|
+
[:code, :description]
|
11
|
+
end
|
12
|
+
|
13
|
+
def other_attributes
|
14
|
+
[
|
15
|
+
:assimilated_VAT_box, :balance_side, :balance_type, :belcotax_type, :compress,
|
16
|
+
:cost_center, :cost_unit, :exclude_VAT_listing, :expense_non_deductible_percentage,
|
17
|
+
:is_blocked, :matching, :private_GL_account, :private_percentage, :reporting_code,
|
18
|
+
:revalue_currency, :searc_code, :type, :use_cost_center, :use_cost_unit,
|
19
|
+
:VAT_code, :VAT_GL_account_type, :VAT_non_deductible_GL_account,
|
20
|
+
:VAT_non_deductible_percentage, :VAT_system, :year_end_cost_GL_account,
|
21
|
+
:year_end_reflection_GL_account
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/elmas/resources/item.rb
CHANGED
@@ -6,12 +6,28 @@ module Elmas
|
|
6
6
|
"logistics/Items"
|
7
7
|
end
|
8
8
|
|
9
|
-
def other_attributes
|
10
|
-
[]
|
11
|
-
end
|
12
|
-
|
13
9
|
def mandatory_attributes
|
14
10
|
[:code, :description]
|
15
11
|
end
|
12
|
+
|
13
|
+
def other_attributes # rubocop:disable Metrics/MethodLength
|
14
|
+
[
|
15
|
+
:class_01, :class_02, :class_03, :class_04, :class_05, :copy_remarks,
|
16
|
+
:cost_price_currency, :cost_price_new, :cost_price_standard, :end_date,
|
17
|
+
:extra_description, :free_bool_field_01, :free_bool_field_02, :free_bool_field_03,
|
18
|
+
:free_bool_field_04, :free_bool_field_05, :free_date_field_01, :free_date_field_02,
|
19
|
+
:free_date_field_03, :free_date_field_04, :free_date_field_05, :free_number_field_01,
|
20
|
+
:free_number_field_02, :free_number_field_03, :free_number_field_04, :free_number_field_05,
|
21
|
+
:free_number_field_06, :free_number_field_07, :free_number_field_08, :free_text_field_01,
|
22
|
+
:free_text_field_02, :free_text_field_03, :free_text_field_04, :free_text_field_05,
|
23
|
+
:free_text_field_06, :free_text_field_07, :free_text_field_08, :free_text_field_09,
|
24
|
+
:free_text_field_10, :GL_costs, :GL_revenue, :GL_stock, :is_batch_item,
|
25
|
+
:is_batch_number_item, :is_fraction_allowed_item, :is_make_item, :is_new_contract,
|
26
|
+
:is_on_demand_item, :is_package_item, :is_registration_code_item, :is_purchase_item,
|
27
|
+
:is_sales_item, :is_serial_item, :is_serial_number_item, :is_stock_item,
|
28
|
+
:is_subcontracted_item, :is_time, :is_webshop_item, :item_group, :notes,
|
29
|
+
:sales_vat_code, :search_code, :security_level, :start_date, :unit
|
30
|
+
]
|
31
|
+
end
|
16
32
|
end
|
17
33
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Elmas
|
2
|
+
class ItemGroup
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def valid_actions
|
6
|
+
[:get]
|
7
|
+
end
|
8
|
+
|
9
|
+
def base_path
|
10
|
+
"logistics/ItemGroups"
|
11
|
+
end
|
12
|
+
|
13
|
+
def other_attributes
|
14
|
+
[:code]
|
15
|
+
end
|
16
|
+
|
17
|
+
def mandatory_attributes
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -11,7 +11,11 @@ module Elmas
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def other_attributes
|
14
|
-
[
|
14
|
+
[
|
15
|
+
:code, :description, :allow_variable_currency, :allow_variable_exchange_rate,
|
16
|
+
:allow_VAT, :auto_save, :bank, :bank_account_ID, :bank_account_including_mask,
|
17
|
+
:currency, :GL_account, :payment_in_transit_account, :type
|
18
|
+
]
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Elmas
|
2
|
+
class Mailbox
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"mailbox/Mailboxes"
|
7
|
+
end
|
8
|
+
|
9
|
+
def other_attributes
|
10
|
+
[
|
11
|
+
:account, :description, :for_division, :publish,
|
12
|
+
:type, :valid_from, :valid_to
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def mandatory_attributes
|
17
|
+
[:mailbox]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Elmas
|
2
|
+
class PurchaseEntry
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"purchaseentry/PurchaseEntries"
|
7
|
+
end
|
8
|
+
|
9
|
+
def mandatory_attributes
|
10
|
+
[:journal, :purchase_entry_lines, :supplier]
|
11
|
+
end
|
12
|
+
|
13
|
+
def other_attributes
|
14
|
+
[
|
15
|
+
:currency, :batch_number, :description, :document, :due_date, :entry_date,
|
16
|
+
:entry_number, :external_link_reference, :invoice_number, :rate, :reporting_period,
|
17
|
+
:reporting_year, :reversal, :VAT_amount_FC, :your_ref
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Elmas
|
2
|
+
class SalesEntry
|
3
|
+
# A sales entry needs multiple sales entry lines
|
4
|
+
# It should also have a journal id and a contact id who ordered it
|
5
|
+
include Elmas::Resource
|
6
|
+
|
7
|
+
def base_path
|
8
|
+
"salesentry/SalesEntries"
|
9
|
+
end
|
10
|
+
|
11
|
+
def mandatory_attributes
|
12
|
+
[:journal, :contact, :sales_entry_lines]
|
13
|
+
end
|
14
|
+
|
15
|
+
def other_attributes
|
16
|
+
[
|
17
|
+
:batch_number, :currency, :customer, :document, :due_date, :entry_date,
|
18
|
+
:entry_number, :invoice_number, :order_number, :payment_condition,
|
19
|
+
:payment_reference, :process_number, :rate, :reporting_period,
|
20
|
+
:reporting_year, :reversal, :VAT_amount_FC, :your_ref
|
21
|
+
]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Elmas
|
2
|
+
class SalesInvoice
|
3
|
+
# An sales_invoice usually has multiple sales_invoice lines
|
4
|
+
# It should also have a journal id and a contact id who ordered it
|
5
|
+
include Elmas::Resource
|
6
|
+
include Elmas::SharedSalesAttributes
|
7
|
+
|
8
|
+
def base_path
|
9
|
+
"salesinvoice/SalesInvoices"
|
10
|
+
end
|
11
|
+
|
12
|
+
def mandatory_attributes
|
13
|
+
[:journal, :ordered_by]
|
14
|
+
end
|
15
|
+
|
16
|
+
def other_attributes
|
17
|
+
SHARED_SALES_ATTRIBUTES.inject(
|
18
|
+
[
|
19
|
+
:sales_invoice_lines, :due_date, :sales_person,
|
20
|
+
:starter_sales_invoice_status, :type
|
21
|
+
],
|
22
|
+
:<<
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Elmas
|
2
|
+
class SalesInvoiceLine
|
3
|
+
# An sales_invoice_line should always have a reference to an item and to an sales_invoice.
|
4
|
+
include Elmas::Resource
|
5
|
+
include Elmas::SharedSalesAttributes
|
6
|
+
|
7
|
+
def base_path
|
8
|
+
"salesinvoice/SalesInvoiceLines"
|
9
|
+
end
|
10
|
+
|
11
|
+
def mandatory_attributes
|
12
|
+
[:item, :invoice_ID]
|
13
|
+
end
|
14
|
+
|
15
|
+
def other_attributes
|
16
|
+
SHARED_LINE_ATTRIBUTES.inject(
|
17
|
+
[
|
18
|
+
:employee, :end_time, :line_number, :start_time, :subscription,
|
19
|
+
:VAT_amount_DC, :VAT_amount_FC
|
20
|
+
],
|
21
|
+
:<<
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Elmas
|
2
|
+
class SalesOrder
|
3
|
+
include Elmas::Resource
|
4
|
+
include Elmas::SharedSalesAttributes
|
5
|
+
|
6
|
+
def base_path
|
7
|
+
"salesorder/SalesOrders"
|
8
|
+
end
|
9
|
+
|
10
|
+
def mandatory_attributes
|
11
|
+
[:sales_order_lines, :ordered_by]
|
12
|
+
end
|
13
|
+
|
14
|
+
def other_attributes
|
15
|
+
SHARED_SALES_ATTRIBUTES.inject(
|
16
|
+
[
|
17
|
+
:deliver_to_contact_person, :delivery_date, :delivery_status,
|
18
|
+
:sales_person, :shipping_method, :status, :tax_schedule, :warehouse_ID
|
19
|
+
],
|
20
|
+
:<<
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Elmas
|
2
|
+
class SalesOrderLine
|
3
|
+
include Elmas::Resource
|
4
|
+
include Elmas::SharedSalesAttributes
|
5
|
+
|
6
|
+
def base_path
|
7
|
+
"salesorder/SalesOrderLines"
|
8
|
+
end
|
9
|
+
|
10
|
+
def mandatory_attributes
|
11
|
+
[:item, :order_ID]
|
12
|
+
end
|
13
|
+
|
14
|
+
def other_attributes
|
15
|
+
SHARED_LINE_ATTRIBUTES.inject(
|
16
|
+
[
|
17
|
+
:amount_FC, :delivery_date, :item_version, :order_number, :unit_price,
|
18
|
+
:use_drop_shipment, :VAT_amount
|
19
|
+
],
|
20
|
+
:<<
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Elmas
|
2
|
+
module SharedSalesAttributes
|
3
|
+
SHARED_SALES_ATTRIBUTES = [
|
4
|
+
:currency, :invoice_to, :invoice_to_contact_person, :invoice_date,
|
5
|
+
:description, :document, :order_date, :ordered_by_contact_person,
|
6
|
+
:tax_schedule, :order_number, :payment_condition, :payment_reference,
|
7
|
+
:remarks, :your_ref
|
8
|
+
]
|
9
|
+
|
10
|
+
SHARED_LINE_ATTRIBUTES = [
|
11
|
+
:discount, :quantity, :amount_FC, :description, :VAT_code, :cost_center,
|
12
|
+
:cost_unit, :VAT_percentage, :unit_code, :tax_schedule, :net_price, :notes,
|
13
|
+
:pricelist, :project
|
14
|
+
]
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Elmas
|
2
|
+
class Transaction
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def valid_actions
|
6
|
+
[:get]
|
7
|
+
end
|
8
|
+
|
9
|
+
def base_path
|
10
|
+
"financialtransaction/Transactions"
|
11
|
+
end
|
12
|
+
|
13
|
+
def mandatory_attributes
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
|
17
|
+
def other_attributes
|
18
|
+
[:description]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Elmas
|
2
|
+
class TransactionLine
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def valid_actions
|
6
|
+
[:get]
|
7
|
+
end
|
8
|
+
|
9
|
+
def base_path
|
10
|
+
"financialtransaction/TransactionLines"
|
11
|
+
end
|
12
|
+
|
13
|
+
def mandatory_attributes
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
|
17
|
+
def other_attributes
|
18
|
+
[:asset_code]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Elmas
|
2
|
+
class VatCode
|
3
|
+
include Elmas::Resource
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"vat/VATCodes"
|
7
|
+
end
|
8
|
+
|
9
|
+
def other_attributes
|
10
|
+
[
|
11
|
+
:account, :calculation_basis, :charged, :EU_sales_listing,
|
12
|
+
:GL_discount_purchase, :GL_discount_sales, :GL_to_claim, :GL_to_pay,
|
13
|
+
:intra_stat, :is_blocked, :legal_text, :tax_return_type, :type,
|
14
|
+
:vat_doc_type, :vat_margin, :VAT_partial_ratio, :VAT_percentages,
|
15
|
+
:VAT_transaction_type
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def mandatory_attributes
|
20
|
+
[:code, :description]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/elmas/response.rb
CHANGED
@@ -7,6 +7,7 @@ module Elmas
|
|
7
7
|
|
8
8
|
def initialize(response)
|
9
9
|
@response = response
|
10
|
+
log_error if fail?
|
10
11
|
end
|
11
12
|
|
12
13
|
def success?
|
@@ -23,7 +24,7 @@ module Elmas
|
|
23
24
|
|
24
25
|
def results
|
25
26
|
results = []
|
26
|
-
if parsed.results
|
27
|
+
if parsed.results
|
27
28
|
parsed.results.each do |attributes|
|
28
29
|
klass = resolve_class
|
29
30
|
results << klass.send(:new, attributes)
|
@@ -32,13 +33,21 @@ module Elmas
|
|
32
33
|
results
|
33
34
|
end
|
34
35
|
|
36
|
+
def result
|
37
|
+
klass = resolve_class
|
38
|
+
klass.send(:new, parsed.result)
|
39
|
+
end
|
40
|
+
|
35
41
|
def first
|
36
|
-
results.first
|
42
|
+
results ? results.first : result
|
37
43
|
end
|
38
44
|
|
39
45
|
def type
|
40
|
-
|
41
|
-
|
46
|
+
if parsed.metadata
|
47
|
+
c_type = parsed.metadata["type"]
|
48
|
+
elsif parsed.results.any?
|
49
|
+
c_type = parsed.results.first["__metadata"]["type"]
|
50
|
+
end
|
42
51
|
c_type.split(".").last
|
43
52
|
end
|
44
53
|
|
@@ -50,6 +59,15 @@ module Elmas
|
|
50
59
|
ERROR_CODES.include? status
|
51
60
|
end
|
52
61
|
|
62
|
+
def error_message
|
63
|
+
parsed.error_message
|
64
|
+
end
|
65
|
+
|
66
|
+
def log_error
|
67
|
+
message = "An error occured, the response had status #{status}. The content of the error was: #{error_message}"
|
68
|
+
Elmas.error(message)
|
69
|
+
end
|
70
|
+
|
53
71
|
def unauthorized?
|
54
72
|
UNAUTHORIZED_CODES.include? status
|
55
73
|
end
|
@@ -63,7 +81,7 @@ module Elmas
|
|
63
81
|
]
|
64
82
|
|
65
83
|
UNAUTHORIZED_CODES = [
|
66
|
-
401, 402, 403
|
84
|
+
400, 401, 402, 403
|
67
85
|
]
|
68
86
|
|
69
87
|
private
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_support/time"
|
3
|
+
require "active_support/core_ext/time/zones"
|
4
|
+
module Elmas
|
5
|
+
module Resource
|
6
|
+
module Sanitizer
|
7
|
+
# Parse the attributes for to post to the API
|
8
|
+
def sanitize
|
9
|
+
to_submit = {}
|
10
|
+
@attributes.each do |key, value|
|
11
|
+
next if key == :id || !valid_attribute?(key)
|
12
|
+
key = Utils.parse_key(key)
|
13
|
+
submit_value = sanitize_relationship(value)
|
14
|
+
to_submit[key] = submit_value
|
15
|
+
end
|
16
|
+
to_submit
|
17
|
+
end
|
18
|
+
|
19
|
+
def sanitize_relationship(value)
|
20
|
+
if value.is_a?(Elmas::Resource)
|
21
|
+
return value.id # Turn relation into ID
|
22
|
+
elsif value.is_a?(Array)
|
23
|
+
return sanitize_has_many(value)
|
24
|
+
elsif value.is_a?(DateTime)
|
25
|
+
return sanitize_date_time(value)
|
26
|
+
elsif value.is_a?(String) && value.match(/(Date\()/)
|
27
|
+
number = value.scan(/\d+/).first.to_i / 1000.0
|
28
|
+
Time.zone = ActiveSupport::TimeZone.new("Europe/Amsterdam")
|
29
|
+
return sanitize_date_time(Time.zone.at(number))
|
30
|
+
else
|
31
|
+
return value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def sanitize_date_time(value)
|
36
|
+
value.strftime("datetime'%Y-%m-%dT%H:%M'")
|
37
|
+
end
|
38
|
+
|
39
|
+
def sanitize_has_many(value)
|
40
|
+
submit_value = []
|
41
|
+
value.each do |e|
|
42
|
+
submit_value << e.sanitize
|
43
|
+
end
|
44
|
+
submit_value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/elmas/uri.rb
CHANGED
@@ -9,7 +9,11 @@ module Elmas
|
|
9
9
|
options.each do |option|
|
10
10
|
send("apply_#{option}".to_sym)
|
11
11
|
end
|
12
|
-
|
12
|
+
if options.include?(:id)
|
13
|
+
uri = URI("#{base_path}(guid'#{id}')")
|
14
|
+
else
|
15
|
+
uri = URI(base_path)
|
16
|
+
end
|
13
17
|
uri.query = URI.encode_www_form(@query)
|
14
18
|
uri
|
15
19
|
end
|
data/lib/elmas/utils.rb
CHANGED
data/lib/elmas/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elmas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marthyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -44,20 +44,34 @@ dependencies:
|
|
44
44
|
- - '='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 2.6.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activesupport
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: bundler
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
|
-
- - "
|
65
|
+
- - ">="
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
67
|
+
version: '0'
|
54
68
|
type: :development
|
55
69
|
prerelease: false
|
56
70
|
version_requirements: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
58
|
-
- - "
|
72
|
+
- - ">="
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
74
|
+
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: rake
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,6 +225,7 @@ files:
|
|
211
225
|
- ".travis.yml"
|
212
226
|
- Gemfile
|
213
227
|
- Guardfile
|
228
|
+
- LICENSE
|
214
229
|
- README.md
|
215
230
|
- Rakefile
|
216
231
|
- bin/console
|
@@ -228,12 +243,33 @@ files:
|
|
228
243
|
- lib/elmas/request.rb
|
229
244
|
- lib/elmas/resource.rb
|
230
245
|
- lib/elmas/resources/account.rb
|
246
|
+
- lib/elmas/resources/bank_entry.rb
|
247
|
+
- lib/elmas/resources/bank_entry_line.rb
|
248
|
+
- lib/elmas/resources/base_entry_line.rb
|
231
249
|
- lib/elmas/resources/contact.rb
|
232
|
-
- lib/elmas/resources/
|
233
|
-
- lib/elmas/resources/
|
250
|
+
- lib/elmas/resources/costcenter.rb
|
251
|
+
- lib/elmas/resources/costunit.rb
|
252
|
+
- lib/elmas/resources/document.rb
|
253
|
+
- lib/elmas/resources/document_attachment.rb
|
254
|
+
- lib/elmas/resources/gl_account.rb
|
234
255
|
- lib/elmas/resources/item.rb
|
256
|
+
- lib/elmas/resources/item_group.rb
|
235
257
|
- lib/elmas/resources/journal.rb
|
258
|
+
- lib/elmas/resources/mailbox.rb
|
259
|
+
- lib/elmas/resources/purchase_entry.rb
|
260
|
+
- lib/elmas/resources/purchase_entry_line.rb
|
261
|
+
- lib/elmas/resources/sales_entry.rb
|
262
|
+
- lib/elmas/resources/sales_entry_line.rb
|
263
|
+
- lib/elmas/resources/sales_invoice.rb
|
264
|
+
- lib/elmas/resources/sales_invoice_line.rb
|
265
|
+
- lib/elmas/resources/sales_order.rb
|
266
|
+
- lib/elmas/resources/sales_order_line.rb
|
267
|
+
- lib/elmas/resources/shared_sales_attributes.rb
|
268
|
+
- lib/elmas/resources/transaction.rb
|
269
|
+
- lib/elmas/resources/transaction_line.rb
|
270
|
+
- lib/elmas/resources/vat_code.rb
|
236
271
|
- lib/elmas/response.rb
|
272
|
+
- lib/elmas/sanitizer.rb
|
237
273
|
- lib/elmas/uri.rb
|
238
274
|
- lib/elmas/utils.rb
|
239
275
|
- lib/elmas/version.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Elmas
|
2
|
-
class Invoice
|
3
|
-
# An invoice usually has multiple invoice lines
|
4
|
-
# It should also have a journal id and a contact id who ordered it
|
5
|
-
include Elmas::Resource
|
6
|
-
|
7
|
-
def base_path
|
8
|
-
"salesinvoice/SalesInvoices"
|
9
|
-
end
|
10
|
-
|
11
|
-
def mandatory_attributes
|
12
|
-
[:journal, :ordered_by]
|
13
|
-
end
|
14
|
-
|
15
|
-
def other_attributes
|
16
|
-
[:sales_invoice_lines, :type]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Elmas
|
2
|
-
class InvoiceLine
|
3
|
-
# An invoice_line should always have a reference to an item and to an invoice.
|
4
|
-
include Elmas::Resource
|
5
|
-
|
6
|
-
def base_path
|
7
|
-
"salesinvoice/SalesInvoiceLines"
|
8
|
-
end
|
9
|
-
|
10
|
-
def mandatory_attributes
|
11
|
-
[:item]
|
12
|
-
end
|
13
|
-
|
14
|
-
def other_attributes
|
15
|
-
[:discount, :quantity, :amount_FC, :description, :vat_code]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|