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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/berbix.rb +28 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98b6319a50dfd32695ad42cc0052df8c7804c4b002c65764ba77ee4db4dc3096
4
- data.tar.gz: ac7ccb91f56cd327f1feee441e029e7cf8d340a1f38d16218ea53f104e4eb0db
3
+ metadata.gz: e6256df46bb179723f2707ce437068058b7422d493e4fbb6e882824d3de12c91
4
+ data.tar.gz: e62c31fb105893010ac0814c876412b214f66f4eaf001afe594c797648c6da5b
5
5
  SHA512:
6
- metadata.gz: 1372ae1a4809b4dc43b537f214cbe2e0caabbfc4bbaa0e1c0e12edb83dbfa927807199b33be2e98bd5b77a7d5fbfa0061a46beeba64b8c2382dd4bda6390e9df
7
- data.tar.gz: 95b9ac13c41f8b2335562858875beb65f49b1571f19abe363e5ac9cea0a98d6ea57eed512e319c79585a7be979b5966a46cc01b548082faba3e44b0f9f9f8b77
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'
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berbix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Levine