berbix 0.0.6 → 0.0.7
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/lib/berbix.rb +28 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6256df46bb179723f2707ce437068058b7422d493e4fbb6e882824d3de12c91
|
4
|
+
data.tar.gz: e62c31fb105893010ac0814c876412b214f66f4eaf001afe594c797648c6da5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2037dcff8958a90f5ddc79cb8d7ad292401a51834fb1a5e5237821ba984e5e6e3cb9963f57d7c7e9c89030838c6583d2dd9dc6c7b88d8e7b50d26d36f433f19
|
7
|
+
data.tar.gz: d168dc65d635a55391186a1338f5f29d83f48d6bbef675235bcfbc7b1be0737153379cfe28c155acb056d4c14fbbc731397386b7570f63a5933babcb8d9fe515
|
data/lib/berbix.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Berbix
|
5
5
|
|
6
|
-
SDK_VERSION = '0.0.
|
6
|
+
SDK_VERSION = '0.0.7'
|
7
7
|
CLOCK_DRIFT = 300
|
8
8
|
|
9
9
|
class HTTPClient
|
@@ -17,6 +17,10 @@ module Berbix
|
|
17
17
|
uri = URI(url)
|
18
18
|
klass = if method == :post
|
19
19
|
Net::HTTP::Post
|
20
|
+
elsif method == :patch
|
21
|
+
Net::HTTP::Patch
|
22
|
+
elsif method == :delete
|
23
|
+
Net::HTTP::Delete
|
20
24
|
else
|
21
25
|
Net::HTTP::Get
|
22
26
|
end
|
@@ -35,6 +39,9 @@ module Berbix
|
|
35
39
|
if code < 200 || code >= 300
|
36
40
|
raise 'unexpected status code returned'
|
37
41
|
end
|
42
|
+
if code == 204
|
43
|
+
return
|
44
|
+
end
|
38
45
|
JSON.parse(res.body)
|
39
46
|
end
|
40
47
|
end
|
@@ -111,6 +118,24 @@ module Berbix
|
|
111
118
|
token_auth_request(:get, tokens, '/v0/transactions')
|
112
119
|
end
|
113
120
|
|
121
|
+
def delete_transaction(tokens)
|
122
|
+
token_auth_request(:delete, tokens, '/v0/transactions')
|
123
|
+
end
|
124
|
+
|
125
|
+
def update_transaction(tokens, opts={})
|
126
|
+
payload = {}
|
127
|
+
payload[:action] = opts[:action] unless opts[:action].nil?
|
128
|
+
payload[:note] = opts[:note] unless opts[:note].nil?
|
129
|
+
token_auth_request(:patch, tokens, '/v0/transactions', data: payload)
|
130
|
+
end
|
131
|
+
|
132
|
+
def override_transaction(tokens, opts={})
|
133
|
+
payload = {}
|
134
|
+
payload[:response_payload] = opts[:response_payload] unless opts[:response_payload].nil?
|
135
|
+
payload[:flags] = opts[:flags] unless opts[:flags].nil?
|
136
|
+
token_auth_request(:patch, tokens, '/v0/transactions/override', data: payload)
|
137
|
+
end
|
138
|
+
|
114
139
|
# This method is deprecated, please use fetch_transaction instead
|
115
140
|
def fetch_user(tokens)
|
116
141
|
fetch_transaction(tokens)
|
@@ -148,14 +173,14 @@ module Berbix
|
|
148
173
|
end
|
149
174
|
end
|
150
175
|
|
151
|
-
def token_auth_request(method, tokens, path)
|
176
|
+
def token_auth_request(method, tokens, path, opts={})
|
152
177
|
refresh_if_necessary!(tokens)
|
153
178
|
headers = {
|
154
179
|
'Authorization' => 'Bearer ' + tokens.access_token,
|
155
180
|
'Content-Type' => 'application/json',
|
156
181
|
'User-Agent' => 'BerbixRuby/' + SDK_VERSION,
|
157
182
|
}
|
158
|
-
@http_client.request(method, @api_host + path, headers)
|
183
|
+
@http_client.request(method, @api_host + path, headers, opts)
|
159
184
|
end
|
160
185
|
|
161
186
|
def fetch_tokens(path, payload)
|