moloni_api 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/lib/moloni_api/api.rb +13 -3
- data/lib/moloni_api/client.rb +10 -1
- data/lib/moloni_api/constants.rb +5 -0
- data/lib/moloni_api/version.rb +1 -1
- data/lib/moloni_api.rb +6 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 673d8af117bb955354df4f2e33b97db71748da48432fa4f3e5cb92d348316e91
|
4
|
+
data.tar.gz: d610ee570e45511f03ad0daf45e6ad07b908c74e49c4bcbbe45ef1069a09bee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519b7cbbdde21394bb9bad14e89a8689352baa80715abce5a6f12af4d3c19c97fb893fdc598796518218dc3420cc083be25f2be2947bdc5002adbbe4ee5c4203
|
7
|
+
data.tar.gz: 25d2849b0bff4f596ff2663044b71e06c08cbee836ed898448f49abdcb307ddfc577e71e1cca338bb3ac682bdd68de289e056823c7f42af015abb76b1bff9342
|
data/CHANGELOG.md
CHANGED
data/lib/moloni_api/api.rb
CHANGED
@@ -14,9 +14,6 @@ module MoloniApi
|
|
14
14
|
include HttpStatusCodes
|
15
15
|
include Dry::Configurable
|
16
16
|
|
17
|
-
API_ENDPOINT = 'https://api.moloni.pt/sandbox/'
|
18
|
-
API_CLIENT_ID = 'apigem'
|
19
|
-
API_CLIENT_SECRET = 'c9c9f4274658da2ad78b55a452894942898b5614'
|
20
17
|
HTTP_STATUS_MAPPING = {
|
21
18
|
HTTP_BAD_REQUEST_CODE => BadRequestError,
|
22
19
|
HTTP_UNAUTHORIZED_CODE => UnauthorizedError,
|
@@ -49,6 +46,19 @@ module MoloniApi
|
|
49
46
|
setting :api_client_id, default: ENV['MOLONI_API_CLIENT_ID'] || API_CLIENT_ID, reader: true
|
50
47
|
setting :api_client_secret, default: ENV['MOLONI_API_CLIENT_SECRET'] || API_CLIENT_SECRET, reader: true
|
51
48
|
|
49
|
+
# Create new API
|
50
|
+
#
|
51
|
+
# @api public
|
52
|
+
def initialize(options = {}, &block)
|
53
|
+
configure do |c|
|
54
|
+
options.each_key do |key|
|
55
|
+
c.send("#{key}=", options[key])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
yield_or_eval(&block) if block_given?
|
60
|
+
end
|
61
|
+
|
52
62
|
# Call block with argument
|
53
63
|
#
|
54
64
|
# @api private
|
data/lib/moloni_api/client.rb
CHANGED
@@ -178,7 +178,16 @@ module MoloniApi
|
|
178
178
|
endpoint: 'customers/insert/',
|
179
179
|
params: { company_id: company_id }.merge(customer_data)
|
180
180
|
)
|
181
|
-
process_response(response)
|
181
|
+
p_res = process_response(response)
|
182
|
+
case p_res
|
183
|
+
when Hash
|
184
|
+
p_res
|
185
|
+
else
|
186
|
+
{
|
187
|
+
valid: 0,
|
188
|
+
errors: p_res
|
189
|
+
}
|
190
|
+
end
|
182
191
|
end
|
183
192
|
|
184
193
|
def invoices_insert(company_id, invoice_params: {}, products: [])
|
data/lib/moloni_api/constants.rb
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
module MoloniApi
|
4
4
|
# Constants
|
5
5
|
module Constants
|
6
|
+
# API Defaults
|
7
|
+
API_ENDPOINT = 'https://api.moloni.pt/sandbox/'
|
8
|
+
API_CLIENT_ID = 'apigem'
|
9
|
+
API_CLIENT_SECRET = 'c9c9f4274658da2ad78b55a452894942898b5614'
|
10
|
+
|
6
11
|
# Response headers
|
7
12
|
RATELIMIT_REMAINING = 'X-RateLimit-Remaining'
|
8
13
|
|
data/lib/moloni_api/version.rb
CHANGED
data/lib/moloni_api.rb
CHANGED
@@ -15,11 +15,14 @@ module MoloniApi
|
|
15
15
|
class << self
|
16
16
|
# Alias for MoloniApi::Client.new
|
17
17
|
#
|
18
|
+
# @param [Hash] options
|
19
|
+
# the configuration options
|
20
|
+
#
|
18
21
|
# @return [MoloniApi::Client]
|
19
22
|
#
|
20
23
|
# @api public
|
21
|
-
def new
|
22
|
-
Client.new
|
24
|
+
def new(options = {}, &block)
|
25
|
+
Client.new(options, &block)
|
23
26
|
end
|
24
27
|
|
25
28
|
# Default middleware stack that uses default adapter as specified
|
@@ -38,17 +41,13 @@ module MoloniApi
|
|
38
41
|
def method_missing(method_name, *args, &block)
|
39
42
|
if new.respond_to?(method_name)
|
40
43
|
new.send(method_name, *args, &block)
|
41
|
-
elsif new.config.respond_to?(method_name)
|
42
|
-
MoloniApi::Client.config.send(method_name, *args, &block)
|
43
44
|
else
|
44
45
|
super.respond_to_missing?
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
def respond_to_missing?(method_name, include_private = false)
|
49
|
-
new.respond_to?(method_name, include_private) ||
|
50
|
-
configuration.respond_to?(method_name) ||
|
51
|
-
super(method_name, include_private)
|
50
|
+
new.respond_to?(method_name, include_private) || super(method_name, include_private)
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moloni_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dinis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|