asaas-ruby 0.2.12 → 0.2.17

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
  SHA256:
3
- metadata.gz: c2ee9c37a26c1a3587826925c96ce00545281c6e39ff042cb2be84b4ddefd502
4
- data.tar.gz: ead4d415f731fae10da6f58bc8c0a3b4d603320db4778186f97e1e72ac085941
3
+ metadata.gz: 94a8d6b0afba265529e845becfadc043fdc70b3c3346726c34b97188b0365885
4
+ data.tar.gz: 1f8b083270382ab6fc2f7ac07273f69287a58400cf0d3b857353e279ed8b5a47
5
5
  SHA512:
6
- metadata.gz: edc52f31943f281d0b420cba0e78f8aff779dbee2da83fe4d5e85adda537d64b91aae2dbab351ac9dc3437d37c89c88630acccd3144fac297db9be1426ff3165
7
- data.tar.gz: dea923e6cd22591ae9f0d5f19b6bde7f820b5de6aca2806f0a3bc9e6298e7933cba9668823c89b995a7ac5204da53fb3da694dee7f741ef399bdac16fd16c236
6
+ metadata.gz: a0a15a87bada9387a1d0a43a418e3f8a33f8e3d34d472f244424114f9045063550c3e75d9d8f7edaf2a89969e25073bcd6f7d8f87772e8d39133dad867bf5112
7
+ data.tar.gz: f778d7b10e0d7b4571f04c943ceb58cee7e31537c49495a5bcc7e308a2cfc974176d7b1b34ea833ebf569b056361de02cb993ead2be7c1492ac16ea016f8ed11
@@ -0,0 +1,20 @@
1
+ c
2
+ body
3
+ c
4
+ body = body.to_json
5
+ body.to_json
6
+ body
7
+ n
8
+ c
9
+ body.compact
10
+ body
11
+ n
12
+ c
13
+ body.to_h
14
+ body
15
+ c
16
+ body.to_h
17
+ body
18
+ c
19
+ body.to_json
20
+ body
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /.idea/
10
+ /.idea/
11
+ *.gem
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.3.3
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ruby-asaas.gemspec
4
- gemspec
4
+ gemspec
data/README.md CHANGED
@@ -0,0 +1,55 @@
1
+ # Asaas Ruby
2
+
3
+ [![Build Status](https://travis-ci.org/thiagodiniz/asaas-ruby.svg?branch=master)](https://travis-ci.org/thiagodiniz/asaas-ruby)
4
+
5
+ A biblioteca Asaas Ruby tem provê um acesso a API Rest do asaas.com.br
6
+
7
+ ## Installation
8
+
9
+ You don't need this source code unless you want to modify the gem. If you just
10
+ want to use the package, just run:
11
+
12
+ ```sh
13
+ gem install asaas-ruby
14
+ ```
15
+
16
+ Para fazer o build da gem
17
+
18
+ ```sh
19
+ gem build asaas-ruby.gemspec
20
+ ```
21
+
22
+ ### Changelog
23
+
24
+ - 0.2.16 - Wallet account tranfers
25
+ - 0.2.15 - Bank account tranfers
26
+
27
+ ### Requirements
28
+
29
+ - Ruby 2.3+.
30
+
31
+ ## Usage
32
+
33
+ ```ruby
34
+ require 'asaas-ruby'
35
+
36
+ Asaas.setup do |config|
37
+ config.token = 'token'
38
+ end
39
+
40
+ asaas_client = Asaas::Client.new()
41
+
42
+ customer = Asaas::Customer.new({name: 'Thiago Diniz', cpfCnpj: '05201932419', email: 'email@example.org'})
43
+ asaas_client.customers.create(customer)
44
+
45
+ charge = Asaas::Payment.new({
46
+ customer: customer.id,
47
+ dueDate: '2019-10-10',
48
+ billingType: 'BOLETO',
49
+ description: "Teste de boleto",
50
+ value: BigDecimal("103.54").to_f,
51
+ postalService: false
52
+ })
53
+
54
+ asaas_client.payments.create(charge)
55
+ ```
@@ -21,8 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.12"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec", "~> 3.2"
24
+ spec.add_development_dependency "webmock", "~> 3.7.2"
25
+
24
26
 
25
- spec.add_dependency "activesupport", "~> 4.2"
27
+ spec.add_dependency "activesupport", '>= 4.2', "< 6"
26
28
  spec.add_dependency "virtus", '~> 1.0', "~> 1.0.5"
27
29
  spec.add_dependency "dry-types", '0.15.0'
28
30
  spec.add_dependency "dry-struct", '0.7.0'
@@ -25,6 +25,7 @@ module Asaas
25
25
  autoload :Fine, 'asaas/models/fine'
26
26
  autoload :Webhook, 'asaas/models/webhook'
27
27
  autoload :Account, 'asaas/models/account'
28
+ autoload :Transfer, 'asaas/models/transfer'
28
29
 
29
30
  class << self
30
31
 
@@ -8,5 +8,6 @@ module Asaas
8
8
  autoload :Payment, 'asaas/api/payment'
9
9
  autoload :Subscription, 'asaas/api/subscription'
10
10
  autoload :Webhook, 'asaas/api/webhook'
11
+ autoload :Transfer, 'asaas/api/transfer'
11
12
  end
12
13
  end
@@ -86,19 +86,26 @@ module Asaas
86
86
  end
87
87
 
88
88
  def request(method, params = {}, body = nil)
89
- body = body && body.respond_to?(:attributes) && body.attributes
89
+ body = body.to_h
90
+ body = body.delete_if { |k, v| v.nil? || v.to_s.empty? }
91
+ body = body.to_json
90
92
  @response = Typhoeus::Request.new(
91
93
  parse_url(params.fetch(:id, false)),
92
94
  method: method,
93
- body: body && body.delete_if { |k, v| v.nil? || v.to_s.empty? },
95
+ body: body,
94
96
  params: params,
95
- headers: { 'access_token': @token || Asaas::Configuration.token }
97
+ headers: {
98
+ 'access_token': @token || Asaas::Configuration.token,
99
+ 'Content-Type': 'application/json'
100
+ },
101
+ verbose: Asaas::Configuration.debug
96
102
  ).run
97
103
  end
98
104
 
99
105
  def response_success
100
106
  entity = nil
101
107
  hash = JSON.parse(@response.body)
108
+ puts hash if Asaas::Configuration.debug
102
109
  if hash.fetch("object", false) === "list"
103
110
  entity = Asaas::Entity::Meta.new(hash)
104
111
  else
@@ -0,0 +1,11 @@
1
+ module Asaas
2
+ module Api
3
+ class Transfer < Asaas::Api::Base
4
+
5
+ def initialize(token, api_version)
6
+ super(token, api_version, '/transfers')
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -32,6 +32,10 @@ module Asaas
32
32
  @subscriptions ||= Asaas::Api::Subscription.new(@token, @api_version)
33
33
  end
34
34
 
35
+ def transfers
36
+ @transfers ||= Asaas::Api::Transfer.new(@token, @api_version)
37
+ end
38
+
35
39
  def webhooks
36
40
  @webhooks ||= Asaas::Api::Webhook.new(@token, @api_version)
37
41
  end
@@ -1,6 +1,7 @@
1
1
  module Asaas
2
2
  class Account < Model
3
3
  attribute :id, Types::Coercible::String.optional.default(nil)
4
+ attribute :walletId, Types::Coercible::String.optional.default(nil)
4
5
  attribute :name, Types::Coercible::String.optional
5
6
  attribute :email, Types::Coercible::String.optional
6
7
  attribute :cpfCnpj, Types::Coercible::String.optional
@@ -11,6 +12,6 @@ module Asaas
11
12
  attribute :complement, Types::Coercible::String.optional
12
13
  attribute :province, Types::Coercible::String.optional
13
14
  attribute :postalCode, Types::Coercible::String.optional
14
- attribute :apiKey, Types::Coercible::String.optional
15
+ attribute :apiKey, Types::Coercible::String.optional.default(nil)
15
16
  end
16
17
  end
@@ -1,6 +1,6 @@
1
1
  module Asaas
2
2
  class Payment < Model
3
- BillingTypes = Types::Strict::String.enum('BOLETO', 'CREDIT_CARD', 'UNDEFINED', 'TRANSFER')
3
+ BillingTypes = Types::Strict::String.enum('BOLETO', 'CREDIT_CARD', 'UNDEFINED', 'TRANSFER', 'DEPOSIT')
4
4
  Status = Types::Strict::String.enum('PENDING', 'RECEIVED', 'CONFIRMED', 'OVERDUE', 'REFUNDED', 'RECEIVED_IN_CASH', 'REFUND_REQUESTED', 'CHARGEBACK_DISPUTE', 'AWAITING_CHARGEBACK_REVERSAL')
5
5
 
6
6
  attribute :id, Types::Coercible::String.optional.default(nil)
@@ -29,6 +29,5 @@ module Asaas
29
29
  attribute :bankSlipUrl, Types::Coercible::String.optional.default(nil)
30
30
  attribute :invoiceNumber, Types::Coercible::String.optional.default(nil)
31
31
  attribute :deleted, Types::Coercible::String.optional.default(nil)
32
-
33
32
  end
34
- end
33
+ end
@@ -0,0 +1,22 @@
1
+ module Asaas
2
+ class Transfer < Model
3
+ Status = Types::Strict::String.enum('PENDING', 'BANK_PROCESSING', 'DONE',
4
+ 'CANCELLED', 'FAILED')
5
+ AccountType = Types::Strict::String.enum('BANK_ACCOUNT','ASAAS_ACCOUNT')
6
+
7
+ attribute :id, Types::Coercible::String.optional.default(nil)
8
+ attribute :dateCreated, Types::Coercible::String.optional.default(nil)
9
+ attribute :value, Types::Coercible::Decimal.optional.default(nil)
10
+ attribute :netValue, Types::Coercible::Decimal.optional.default(nil)
11
+ attribute :transferFee, Types::Coercible::Decimal.optional.default(nil)
12
+ attribute :status, Status.optional.default(nil)
13
+ attribute :effectiveDate, Types::Coercible::String.optional.default(nil)
14
+ attribute :scheduleDate, Types::Coercible::String.optional.default(nil)
15
+ attribute :authorized, Types::Coercible::String.optional.default(nil)
16
+ attribute :transactionReceiptUrl, Types::Coercible::String.optional.default(nil)
17
+ attribute :bankAccount, Types::Coercible::Hash.optional.default(nil)
18
+ attribute :type, AccountType.optional.default(nil)
19
+ attribute :walletId, Types::Coercible::String.optional.default(nil)
20
+ attribute :account, Types::Coercible::Hash.optional.default(nil)
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  Dry::Types.load_extensions(:maybe)
2
2
 
3
3
  module Types
4
- include Dry::Types.module
4
+ include Dry::Types(default: :nominal)
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Asaas
2
- VERSION = "0.2.12"
2
+ VERSION = "0.2.17"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asaas-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Junior
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-17 00:00:00.000000000 Z
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,39 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
- name: activesupport
56
+ name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.7.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.7.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '4.2'
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '6'
62
79
  type: :runtime
63
80
  prerelease: false
64
81
  version_requirements: !ruby/object:Gem::Requirement
65
82
  requirements:
66
- - - "~>"
83
+ - - ">="
67
84
  - !ruby/object:Gem::Version
68
85
  version: '4.2'
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '6'
69
89
  - !ruby/object:Gem::Dependency
70
90
  name: virtus
71
91
  requirement: !ruby/object:Gem::Requirement
@@ -195,6 +215,7 @@ executables: []
195
215
  extensions: []
196
216
  extra_rdoc_files: []
197
217
  files:
218
+ - ".byebug_history"
198
219
  - ".gitignore"
199
220
  - ".rspec"
200
221
  - ".ruby-gemset"
@@ -214,6 +235,7 @@ files:
214
235
  - lib/asaas/api/notification.rb
215
236
  - lib/asaas/api/payment.rb
216
237
  - lib/asaas/api/subscription.rb
238
+ - lib/asaas/api/transfer.rb
217
239
  - lib/asaas/api/webhook.rb
218
240
  - lib/asaas/client.rb
219
241
  - lib/asaas/configuration.rb
@@ -237,6 +259,7 @@ files:
237
259
  - lib/asaas/models/interest.rb
238
260
  - lib/asaas/models/model.rb
239
261
  - lib/asaas/models/payment.rb
262
+ - lib/asaas/models/transfer.rb
240
263
  - lib/asaas/models/webhook.rb
241
264
  - lib/asaas/types.rb
242
265
  - lib/asaas/version.rb
@@ -258,8 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
281
  - !ruby/object:Gem::Version
259
282
  version: '0'
260
283
  requirements: []
261
- rubyforge_project:
262
- rubygems_version: 2.7.9
284
+ rubygems_version: 3.0.6
263
285
  signing_key:
264
286
  specification_version: 4
265
287
  summary: Asass.com Ruby API Wrapper