tangocard 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd29a51b8650b514dc09bc278ce37740e9957153
4
- data.tar.gz: 618da4ddf55e67a5554addd734478ef14a22054d
3
+ metadata.gz: 8b8c6e8dd748f73ba39b6300e69450556158be90
4
+ data.tar.gz: eea2b48a8cd364c9f79871e93011467d34df83d2
5
5
  SHA512:
6
- metadata.gz: dae579cabb4edef980a2d8ad4bd5d55a1eac81d4a927f01b6b652e8dc408abb0c143e1dcacdad82a152e2add327e56c5612610fa18589bce0775c9884be36b67
7
- data.tar.gz: a605a79b85e12710d16c352a08516e43e371340b5d5ebb61ebc27f4749cd652b6baa0c9919ffdeffd0849b2c2948a5e41a98de0f84d494b343340217d2be8ef6
6
+ metadata.gz: f1c2a0c08a8962c0cd89153bf5e20a4e19a95653a9632884acb18941e02e5f437653f2a3f5c1b3454ae4d265dead80605c77ab09ceffc08dc822fdebf3d2fc78
7
+ data.tar.gz: 6b680dbf60193d42cfafdd4ae5e0719b6b64700594bbfcc081666712ddce9888b8aed439f3d22797112e9060a58b1967050532e596d8e40d3108a099648f44ed
@@ -30,8 +30,11 @@ require 'tangocard/raas'
30
30
  require 'tangocard/account'
31
31
  require 'tangocard/account_create_failed_exception'
32
32
  require 'tangocard/account_not_found_exception'
33
+ require 'tangocard/account_delete_credit_card_failed_exception'
34
+ require 'tangocard/account_register_credit_card_failed_exception'
35
+ require 'tangocard/account_fund_failed_exception'
33
36
  require 'tangocard/brand'
34
37
  require 'tangocard/order'
35
38
  require 'tangocard/order_create_failed_exception'
36
39
  require 'tangocard/order_not_found_exception'
37
- require 'tangocard/reward'
40
+ require 'tangocard/reward'
@@ -1,5 +1,5 @@
1
1
  class Tangocard::Account
2
- attr_reader :customer, :identifier, :email, :available_balance
2
+ attr_reader :customer, :identifier, :email, :available_balance, :cc_token
3
3
 
4
4
  private_class_method :new
5
5
 
@@ -71,10 +71,98 @@ class Tangocard::Account
71
71
  @available_balance
72
72
  end
73
73
 
74
+ # Register a credit card
75
+ # Raises Tango::AccountRegisterCreditCardFailedException on failure.
76
+ # Example:
77
+ # >> account.register_credit_card('128.128.128.128', Hash (see example below))
78
+ # => {"success"=>true, "cc_token"=>"33041234", "active_date"=>1439286111}
79
+ #
80
+ # Arguments:
81
+ # client_ip: (String)
82
+ # credit_card: (Hash) - see
83
+ # https://github.com/tangocarddev/RaaS/blob/master/cc_register.schema.json for details
84
+ #
85
+ # Credit Card Hash Example:
86
+ #
87
+ # {
88
+ # 'number' => '4111111111111111',
89
+ # 'expiration' => '01/17',
90
+ # 'security_code' => '123',
91
+ # 'billing_address' => {
92
+ # 'f_name' => 'Jane',
93
+ # 'l_name' => 'User',
94
+ # 'address' => '123 Main Street',
95
+ # 'city' => 'Anytown',
96
+ # 'state' => 'NY',
97
+ # 'zip' => '11222',
98
+ # 'country' => 'USA',
99
+ # 'email' => 'jane@company.com'
100
+ # }
101
+ # }
102
+ def register_credit_card(client_ip, credit_card)
103
+ params = {
104
+ 'client_ip' => client_ip,
105
+ 'credit_card' => credit_card,
106
+ 'customer' => customer,
107
+ 'account_identifier' => identifier
108
+ }
109
+
110
+ response = Tangocard::Raas.register_credit_card(params)
111
+ if response.success?
112
+ @cc_token = response.parsed_response['cc_token']
113
+ response.parsed_response
114
+ else
115
+ raise Tangocard::AccountRegisterCreditCardFailedException, "#{response.denial_message}"
116
+ end
117
+ end
118
+
119
+ # Add funds to the account.
120
+ # Raises Tangocard::AccountFundFailedException on failure.
121
+ # Example:
122
+ # >> account.cc_fund(5000, '128.128.128.128', '12345678', '123')
123
+ # => {"success"=>true, "fund_id"=>"RF13-09261098-12", "amount"=>5000}
124
+
125
+ # Arguments:
126
+ # amount: (Integer)
127
+ # client_ip: (String)
128
+ # cc_token: (String)
129
+ # security_code: (String)
130
+ # def cc_fund(amount, client_ip, cc_token, security_code)
131
+ # params = {
132
+ # 'amount' => amount,
133
+ # 'client_ip' => client_ip,
134
+ # 'cc_token' => cc_token,
135
+ # 'customer' => customer,
136
+ # 'account_identifier' => identifier,
137
+ # 'security_code' => security_code
138
+ # }
139
+ #
140
+ # response = Tangocard::Raas.cc_fund_account(params)
141
+ # end
142
+ #
143
+ def cc_fund(amount, client_ip, cc_token, security_code)
144
+ params = {
145
+ 'amount' => amount,
146
+ 'client_ip' => client_ip,
147
+ 'cc_token' => cc_token,
148
+ 'customer' => customer,
149
+ 'account_identifier' => identifier,
150
+ 'security_code' => security_code
151
+ }
152
+
153
+ response = Tangocard::Raas.cc_fund_account(params)
154
+ if response.success?
155
+ response.parsed_response
156
+ else
157
+ raise Tangocard::AccountFundFailedException, "#{response.error_message} #{response.denial_message} #{response.invalid_inputs}"
158
+ end
159
+ end
160
+
161
+ # (DEPRECATED)
74
162
  # Add funds to the account.
75
163
  #
76
164
  # Example:
77
- # >> account.fund(10000, '128.128.128.128', Hash (see example below))
165
+ # >> account.fund!(10000, '128.128.128.128', Hash (see example below))
78
166
  # => #<Tangocard::Account:0x007f9a6fec0138 @customer="bonusly", @email="dev@bonus.ly", @identifier="test", @available_balance=0>
79
167
  #
80
168
  # Arguments:
@@ -100,6 +188,8 @@ class Tangocard::Account
100
188
  # }
101
189
  # }
102
190
  def fund!(amount, client_ip, credit_card)
191
+ warn "[DEPRECATION] `fund!` is deprecated. Please use `cc_fund` instead. See https://github.com/tangocarddev/RaaS#fund-a-platforms-account"
192
+
103
193
  params = {
104
194
  'amount' => amount,
105
195
  'client_ip' => client_ip,
@@ -109,4 +199,28 @@ class Tangocard::Account
109
199
  }
110
200
  Tangocard::Raas.fund_account(params)
111
201
  end
112
- end
202
+
203
+ # Delete a credit card from an account
204
+ # Raises Tangocard::AccountDeleteCreditCardFailedException failure.
205
+ # Example:
206
+ # >> account.delete_credit_card("12345678")
207
+ # => {"success"=>true, "message": "This card is no longer present in the system"}
208
+
209
+ # Arguments:
210
+ # cc_token: (String)
211
+ def delete_credit_card(cc_token)
212
+ params = {
213
+ 'cc_token' => cc_token,
214
+ 'customer' => customer,
215
+ 'account_identifier' => identifier
216
+ }
217
+
218
+ response = Tangocard::Raas.delete_credit_card(params)
219
+ if response.success?
220
+ response.parsed_response
221
+ else
222
+ raise Tangocard::AccountDeleteCreditCardFailedException, "#{response.error_message}"
223
+ end
224
+ end
225
+
226
+ end
@@ -0,0 +1,3 @@
1
+ class Tangocard::AccountDeleteCreditCardFailedException < Exception
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Tangocard::AccountFundFailedException < Exception
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Tangocard::AccountRegisterCreditCardFailedException < Exception
2
+
3
+ end
@@ -25,6 +25,7 @@ class Tangocard::Raas
25
25
  Tangocard::Response.new(get(endpoint + "/accounts/#{params['customer']}/#{params['identifier']}", basic_auth_param))
26
26
  end
27
27
 
28
+ # (Deprecated)
28
29
  # Funds an account. Returns Tangocard::Response object.
29
30
  #
30
31
  # Example:
@@ -37,6 +38,42 @@ class Tangocard::Raas
37
38
  Tangocard::Response.new(post(endpoint + '/funds', {:body => params.to_json}.merge(basic_auth_param)))
38
39
  end
39
40
 
41
+ # Funds an account. Returns Tangocard::Response object.
42
+ #
43
+ # Example:
44
+ # >> Tangocard::Raas.cc_fund_account(params)
45
+ # => #<Tangocard::Response:0x007f9a6c4bca68 ...>
46
+ #
47
+ # Arguments:
48
+ # params: (Hash - see https://github.com/tangocarddev/RaaS#fund-resources for details)
49
+ def self.cc_fund_account(params)
50
+ Tangocard::Response.new(post(endpoint + '/cc_fund', {:body => params.to_json}.merge(basic_auth_param)))
51
+ end
52
+
53
+ # Registers a credit card to an account. Returns Tangocard::Response object.
54
+ #
55
+ # Example:
56
+ # >> Tangocard::Raas.register_credit_card(params)
57
+ # => #<Tangocard::Response:0x007f9a6c4bca68 ...>
58
+ #
59
+ # Arguments:
60
+ # params: (Hash - see https://github.com/tangocarddev/RaaS#fund-resources for details)
61
+ def self.register_credit_card(params)
62
+ Tangocard::Response.new(post(endpoint + '/cc_register', {:body => params.to_json}.merge(basic_auth_param)))
63
+ end
64
+
65
+ # Deletes a credit card from an account. Returns Tangocard::Response object.
66
+ #
67
+ # Example:
68
+ # >> Tangocard::Raas.delete_credit_card(params)
69
+ # => #<Tangocard::Response:0x007f9a6c4bca68 ...>
70
+ #
71
+ # Arguments:
72
+ # params: (Hash - see https://github.com/tangocarddev/RaaS#delete-a-credit-card-from-an-account for details)
73
+ def self.delete_credit_card(params)
74
+ Tangocard::Response.new(post(endpoint + '/cc_unregister', {:body => params.to_json}.merge(basic_auth_param)))
75
+ end
76
+
40
77
  # Retrieve all rewards. Returns Tangocard::Response object.
41
78
  #
42
79
  # Example:
@@ -110,4 +147,4 @@ class Tangocard::Raas
110
147
  def self.endpoint
111
148
  Tangocard.configuration.base_uri + '/raas/v1'
112
149
  end
113
- end
150
+ end
@@ -14,7 +14,11 @@ class Tangocard::Response
14
14
  parsed_response['error_message'] rescue 'UNKNOWN ERROR'
15
15
  end
16
16
 
17
+ def denial_message
18
+ parsed_response['denial_message'] rescue 'UNKNOWN ERROR'
19
+ end
20
+
17
21
  def invalid_inputs
18
22
  parsed_response['invalid_inputs'] rescue 'UNKNOWN INVALID INPUTS'
19
23
  end
20
- end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module Tangocard
2
- VERSION = '4.0.0'
2
+ VERSION = '4.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tangocard
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Crawford-Marks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-04 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -95,7 +95,10 @@ files:
95
95
  - lib/tangocard.rb
96
96
  - lib/tangocard/account.rb
97
97
  - lib/tangocard/account_create_failed_exception.rb
98
+ - lib/tangocard/account_delete_credit_card_failed_exception.rb
99
+ - lib/tangocard/account_fund_failed_exception.rb
98
100
  - lib/tangocard/account_not_found_exception.rb
101
+ - lib/tangocard/account_register_credit_card_failed_exception.rb
99
102
  - lib/tangocard/brand.rb
100
103
  - lib/tangocard/order.rb
101
104
  - lib/tangocard/order_create_failed_exception.rb