uphold 1.1.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebb5550fb10ca88ce0da7249bca1d44748dd1bf6
4
- data.tar.gz: 914cfa1a512e956e35906add853e6410808c9ef1
3
+ metadata.gz: 6b06b5b6b81ab035ed8ed1c06625127d682d57ac
4
+ data.tar.gz: 5bd5cdb7d9c5c12b4809e91c52c9028fb1ee1152
5
5
  SHA512:
6
- metadata.gz: 9f56e63017a63d15c1a048e0769bd3e1635492db03f9975b188661ab27219282079287f66bfead96ebeb699cbe79cfbc784f4c204674d0583e4ed1489d3e5924
7
- data.tar.gz: 1bab6ef13383591fa84afa237b359405e1337f4bb864b50c3c2b47e1df0362bb93cc064aecd44acf9fcd4a8eab01c3592460276eeeaa6d29077892c278f76132
6
+ metadata.gz: 07b191dcb567fe6e7d6e1b1f7b021c9e432307800d65b30f5c54234661a06f3e6380b7e3c07aa91b824c6fbc51746775657be218599cf8a72da7aa1a93c2ef6f
7
+ data.tar.gz: dbc6966ce2dc0c278bb332bd3d628b109824f67dae5a0bafaa942236f7e2430365177565de06f470dce38a07b99d2a8e874a75882f90ffc4917f052d5fec0862
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Uphold
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/uphold-ruby.svg)](http://badge.fury.io/rb/uphold)
4
- [![Build Status](https://travis-ci.org/subvisual/uphold-ruby.svg?branch=master)](https://travis-ci.org/subvisual/uphold-ruby)
5
- [![Code Climate](https://codeclimate.com/github/subvisual/uphold-ruby/badges/gpa.svg)](https://codeclimate.com/github/subvisual/uphold-ruby)
6
- [![Test Coverage](https://codeclimate.com/github/subvisual/uphold-ruby/badges/coverage.svg)](https://codeclimate.com/github/subvisual/uphold-ruby)
3
+ [![Gem Version](https://badge.fury.io/rb/uphold.svg)](http://badge.fury.io/rb/uphold)
4
+ [![Build Status](https://travis-ci.org/subvisual/uphold-sdk-ruby.svg?branch=master)](https://travis-ci.org/subvisual/uphold-sdk-ruby)
5
+ [![Code Climate](https://codeclimate.com/github/subvisual/uphold-sdk-ruby/badges/gpa.svg)](https://codeclimate.com/github/subvisual/uphold-sdk-ruby)
6
+ [![Test Coverage](https://codeclimate.com/github/subvisual/uphold-sdk-ruby/badges/coverage.svg)](https://codeclimate.com/github/subvisual/uphold-sdk-ruby/coverage)
7
7
 
8
8
  A ruby client for the [Uphold](https://uphold.com/) API.
9
9
 
@@ -219,6 +219,13 @@ client.commit_transaction(card_id: 'a6d35fcd-xxxx-9c9d1dda6d57', transaction_id:
219
219
  'd51b4e4e-9827-40fb-8763-e0ea2880085b')
220
220
  ```
221
221
 
222
+ **Create and commit a transaction in a single request:**
223
+
224
+ ```ruby
225
+ client.create_and_commit_transaction(card_id: 'a6d35fcd-xxxx-9c9d1dda6d57', currency:
226
+ 'BTC', amount: 0.1, destination: 'foo@bar.com')
227
+ ```
228
+
222
229
  **Cancel a transaction:**
223
230
 
224
231
  ```ruby
@@ -7,15 +7,19 @@ module Uphold
7
7
  request_data = Uphold::RequestData.new(
8
8
  Endpoints::AUTH,
9
9
  Entities::AuthToken,
10
- {
11
- 'X-Uphold-OTP' => otp,
12
- 'X-Bitreserve-OTP' => otp,
13
- 'Authorization' => 'Basic ' + Base64.encode64("#{username}:#{password}")
14
- },
10
+ auth_headers(username, password, otp),
15
11
  description: 'Uphold ruby'
16
12
  )
17
13
  Request.perform_with_object(:post, request_data)
18
14
  end
15
+
16
+ def auth_headers(username, password, otp)
17
+ {
18
+ 'X-Uphold-OTP' => otp,
19
+ 'X-Bitreserve-OTP' => otp,
20
+ 'Authorization' => 'Basic ' + Base64.encode64("#{username}:#{password}")
21
+ }
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -3,6 +3,7 @@ module Uphold
3
3
  AUTH = '/me/tokens'
4
4
  CARD = '/me/cards'
5
5
  CARD_PRIVATE_TRANSACTIONS = CARD + '/:card/transactions'
6
+ CREATE_AND_COMMIT_TRANSACTION = CARD_PRIVATE_TRANSACTIONS + '?commit=true'
6
7
  COMMIT_TRANSACTION = CARD_PRIVATE_TRANSACTIONS + '/:id/commit'
7
8
  CANCEL_TRANSACTION = CARD_PRIVATE_TRANSACTIONS + '/:id/cancel'
8
9
  RESEND_TRANSACTION = CARD_PRIVATE_TRANSACTIONS + '/:id/resend'
@@ -16,6 +16,16 @@ module Uphold
16
16
  Request.perform_with_object(:post, request_data)
17
17
  end
18
18
 
19
+ def create_and_commit_transaction(card_id: nil, currency: nil, amount: 0, destination: nil)
20
+ request_data = RequestData.new(
21
+ Endpoints.with_placeholders(Endpoints::CREATE_AND_COMMIT_TRANSACTION, ':card' => card_id),
22
+ Entities::Transaction,
23
+ authorization_header,
24
+ card_id: card_id, denomination: { currency: currency, amount: amount }, destination: destination
25
+ )
26
+ Request.perform_with_object(:post, request_data)
27
+ end
28
+
19
29
  def cancel_transaction(card_id: nil, transaction_id: nil)
20
30
  request_data = transaction_request_data(Endpoints::CANCEL_TRANSACTION, card_id, transaction_id)
21
31
  Request.perform_with_object(:post, request_data)
@@ -1,3 +1,3 @@
1
1
  module Uphold
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -41,6 +41,24 @@ module Uphold
41
41
  end
42
42
  end
43
43
 
44
+ context '#create_and_commit_transaction' do
45
+ it 'creates a transaction for a specific card' do
46
+ card_id = '1234'
47
+ request_data = RequestData.new(
48
+ Endpoints.with_placeholders(Endpoints::CREATE_AND_COMMIT_TRANSACTION, ':card' => card_id),
49
+ Entities::Transaction,
50
+ client.authorization_header,
51
+ card_id: card_id, denomination: { currency: 'USD', amount: 10 }, destination: 'foo@bar.com'
52
+ )
53
+ allow(Request).to receive(:perform_with_object)
54
+
55
+ client.create_and_commit_transaction(card_id: card_id, currency: 'USD', amount: 10, destination: 'foo@bar.com')
56
+
57
+ expect(Request).to have_received(:perform_with_object).
58
+ with(:post, request_data)
59
+ end
60
+ end
61
+
44
62
  context '#cancel_transaction' do
45
63
  it 'cancels a transaction for a specific card' do
46
64
  card_id = '1234'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uphold
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subvisual
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2016-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  version: '0'
246
246
  requirements: []
247
247
  rubyforge_project:
248
- rubygems_version: 2.4.8
248
+ rubygems_version: 2.5.1
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: A wrapper for the Uphold API