bcash-ruby 0.1.2 → 0.1.3

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: 7c4ce1f2865bf87f94925e7a6a63f52f0f05ca78
4
- data.tar.gz: cf3e7dc47d834ee16058b3a079f28c5ed5b6355c
3
+ metadata.gz: 1f8e0061d8fdb251e5eb6505f3ad22a80e4a5db2
4
+ data.tar.gz: d70dedbd8cba1a5f304e9d9618a20c1810e148f3
5
5
  SHA512:
6
- metadata.gz: e628d428a87577c6652de0e6103f6789144688efcbd6294887cc00a56c3d0277fa74066d82d888d97ad8629e86f33f266fdf04820bb7568f6882d813553c4a4b
7
- data.tar.gz: 47ea448c33bfa19ae04503553010f0c605e0e64464c8115df8fae8a739de3bc4823c4808984d72acd383466c2cbcf843f12642f5045ed0aaf70bb85457d121ed
6
+ metadata.gz: 987c5cd5ff478a707152f32ddf4c8b5eb75b3806c9404866032c2d36e22c30c763b54cefb64409c6e57c3e363ca1657e7cbda88a03fc5c7c8c2e8fd91e03e16b
7
+ data.tar.gz: 3f2ba02f67ca23998b0f4da87f65bc96b24ef05b7387218ed0e8104b826db95e13ea4c6cf9891df67722b5993b523c982df0a94fc26023f4d826b01d4625c20b
@@ -0,0 +1,14 @@
1
+ module Bcash::Api
2
+ class AccountNotValidResponse < Response
3
+ attr_accessor :account
4
+
5
+ def initialize(account)
6
+ self.success = false
7
+ self.account = account
8
+ end
9
+
10
+ def message
11
+ @account.errors_full_messages
12
+ end
13
+ end
14
+ end
@@ -12,7 +12,7 @@ module Bcash::Api
12
12
  response = json_request :post, 'createAccount', data
13
13
  Bcash::Api::AccountResponse.new(response)
14
14
  else
15
- raise Bcash::InvalidAccount
15
+ Bcash::Api::AccountNotValidResponse.new(data)
16
16
  end
17
17
  end
18
18
  end
@@ -21,6 +21,11 @@ module Bcash::Api
21
21
  legal_person.present? ? legal_person.valid? : true
22
22
  end
23
23
 
24
+ def errors_full_messages
25
+ errors.full_messages + address.errors.full_messages + owner.errors.full_messages +
26
+ contact.errors.full_messages
27
+ end
28
+
24
29
  def attributes
25
30
  { 'owner' => owner, 'legalPerson' => legal_person, 'address' => address, 'contact' => contact, 'url' => url, 'transactionMode' => transaction_mode }
26
31
  end
data/lib/bcash/api.rb CHANGED
@@ -2,6 +2,7 @@ module Bcash::Api
2
2
  autoload :Accounts, 'bcash/api/accounts'
3
3
  autoload :Response, 'bcash/api/response'
4
4
  autoload :AccountResponse, 'bcash/api/account_response'
5
+ autoload :AccountNotValidResponse, 'bcash/api/account_not_valid_response'
5
6
 
6
7
  autoload :BaseRequest, 'bcash/api/request/base_request'
7
8
  autoload :AddressRequest, 'bcash/api/request/address_request'
data/lib/bcash/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bcash
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -101,14 +101,18 @@ describe Bcash::Api::Accounts do
101
101
 
102
102
  context 'when all required fields are missing' do
103
103
  it 'must raise error' do
104
- expect { client.create_account({}) }.to raise_error(Bcash::InvalidAccount)
104
+ response = client.create_account({})
105
+ expect(response).to_not be_success
106
+ expect(response.message).to eq(["Email can't be blank", "Gender can't be blank", "Name can't be blank", "Cpf can't be blank"])
105
107
  end
106
108
  end
107
109
 
108
110
  context 'when cpf is missing' do
109
111
  it 'must raise error' do
110
112
  data[:owner].delete(:cpf)
111
- expect { client.create_account(data) }.to raise_error(Bcash::InvalidAccount)
113
+ response = client.create_account(data)
114
+ expect(response).to_not be_success
115
+ expect(response.message).to eq(["Cpf can't be blank"])
112
116
  end
113
117
  end
114
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcash-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -184,6 +184,7 @@ files:
184
184
  - bcash-ruby.gemspec
185
185
  - lib/bcash.rb
186
186
  - lib/bcash/api.rb
187
+ - lib/bcash/api/account_not_valid_response.rb
187
188
  - lib/bcash/api/account_response.rb
188
189
  - lib/bcash/api/accounts.rb
189
190
  - lib/bcash/api/request/account_creation_request.rb