myob_acumatica 0.1.0 → 0.1.1
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/.rubocop.yml +27 -0
- data/Gemfile.lock +2 -0
- data/README.md +189 -52
- data/examples/app.rb +114 -19
- data/examples/customer.rb +128 -0
- data/examples/dummy.pdf +0 -0
- data/examples/invoice.rb +121 -0
- data/lib/myob_acumatica/api/customer.rb +322 -0
- data/lib/myob_acumatica/api/http.rb +49 -0
- data/lib/myob_acumatica/api/invoice.rb +354 -0
- data/lib/myob_acumatica/api.rb +6 -0
- data/lib/myob_acumatica/o_auth_2/http.rb +26 -0
- data/lib/myob_acumatica/o_auth_2/token.rb +119 -0
- data/lib/myob_acumatica/version.rb +1 -1
- data/lib/myob_acumatica.rb +19 -4
- metadata +28 -7
- data/lib/myob_acumatica/customer.rb +0 -26
- data/lib/myob_acumatica/o_auth_2.rb +0 -59
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module MyobAcumatica
|
4
|
-
module OAuth2
|
5
|
-
module_function
|
6
|
-
|
7
|
-
def authorize_url(instance_url:, client_id:, redirect_uri:, scope:)
|
8
|
-
"https://#{instance_url}/identity/connect/authorize?#{URI.encode_www_form({
|
9
|
-
response_type: 'code',
|
10
|
-
client_id: client_id,
|
11
|
-
redirect_uri: redirect_uri,
|
12
|
-
scope: scope
|
13
|
-
})}"
|
14
|
-
end
|
15
|
-
|
16
|
-
def authorize_token(instance_url:, client_id:, client_secret:, code:, redirect_uri:, logger: nil)
|
17
|
-
Http.post(
|
18
|
-
uri: URI("https://#{instance_url}/identity/connect/token"),
|
19
|
-
body: {
|
20
|
-
grant_type: 'authorization_code',
|
21
|
-
client_id: client_id,
|
22
|
-
client_secret: client_secret,
|
23
|
-
code: code,
|
24
|
-
redirect_uri: redirect_uri
|
25
|
-
},
|
26
|
-
logger: logger
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
def refresh_token(instance_url:, client_id:, client_secret:, refresh_token:, logger: nil)
|
31
|
-
Http.post(
|
32
|
-
uri: URI("https://#{instance_url}/identity/connect/token"),
|
33
|
-
body: {
|
34
|
-
grant_type: 'refresh_token',
|
35
|
-
client_id: client_id,
|
36
|
-
client_secret: client_secret,
|
37
|
-
refresh_token: refresh_token
|
38
|
-
},
|
39
|
-
logger: logger
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
module Http
|
44
|
-
module_function
|
45
|
-
|
46
|
-
def post(uri:, body:, logger: nil)
|
47
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
48
|
-
http.use_ssl = uri.scheme == 'https'
|
49
|
-
http.set_debug_output(logger) if logger
|
50
|
-
|
51
|
-
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/x-www-form-urlencoded')
|
52
|
-
request.set_form_data(body)
|
53
|
-
response = http.request(request)
|
54
|
-
|
55
|
-
JSON.parse(response.body)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|