boletosimples 0.3.1 → 0.4.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: cec6e36da74f8575199f3f49c90982ca623a8c62
4
- data.tar.gz: e0f17f8fd39c36da2ecc6d19ecbe104d7ac82386
3
+ metadata.gz: 490d1c76e70d03fec1a8578e593b6a18e6c58f1e
4
+ data.tar.gz: ffc415cf01929b2237ce2dc928460973cda9516c
5
5
  SHA512:
6
- metadata.gz: 561ec390a91dea36b12b8864d2ffdcd810c021b3f6572c9da360c1ac27dbca49f7dfcee76ce48170d443f5140cd0b3b5c73fa81b6be491ba12ff4b0d5e6578c3
7
- data.tar.gz: 1e328b9815b30fea86c37b97d07180046e5a5b4e42a4e6a706f202f60d31649430610651a56749d6ab56b2ac12c3769a8ec58b44086311042b2b9957c79914ba
6
+ metadata.gz: 9bd04063532e772ab874480ce21af8c8a6108b2649857062ea4aed159586078a96c76b492c03412c099d025fd1d9812745f5fea3c6440f4021a8b03cda1b8125
7
+ data.tar.gz: c6aaa930072ad9c2d954c5b5f400496aaba2ee25426f8b999634db769526080f8d5becdbc76b4d64168cb7f34a791e96d9911ded6a7ccae96aa14860f33ed541
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.3.1
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - '2.3.1'
3
4
  - '2.2.1'
4
5
  - '2.1.0'
5
- - '2.0.0'
6
6
  branches:
7
7
  only:
8
8
  - master
@@ -21,16 +21,17 @@ Gem::Specification.new do |gem|
21
21
  gem.required_ruby_version = '>= 1.9'
22
22
 
23
23
  # Gems that must be intalled for boletosimples to work
24
- gem.add_dependency 'her', '~> 0.7.5'
24
+ gem.add_dependency 'her', '~> 0.8.1'
25
25
  gem.add_dependency 'faraday_middleware', '~> 0.10.0'
26
- gem.add_dependency 'faraday-http-cache', '~> 1.2.0'
26
+ gem.add_dependency 'faraday-http-cache', '~> 1.3.1'
27
27
 
28
28
  # Gems that must be installed for boletosimples to compile and build
29
29
  gem.add_development_dependency 'pry', '~> 0.10.1'
30
- gem.add_development_dependency 'rspec', '~> 3.3.0'
31
- gem.add_development_dependency 'vcr', '~> 2.9'
32
- gem.add_development_dependency 'webmock', '~> 1.21.0'
33
- gem.add_development_dependency 'rake', '~> 10.4.2'
30
+ gem.add_development_dependency 'rspec', '~> 3.5.0'
31
+ gem.add_development_dependency 'vcr', '~> 3.0'
32
+ gem.add_development_dependency 'webmock', '~> 2.1.0'
33
+ gem.add_development_dependency 'rake', '~> 11.2.2'
34
34
  gem.add_development_dependency 'coveralls', '~> 0.8.2'
35
- gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.7'
35
+ gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.6.0'
36
+ gem.add_development_dependency 'rubocop'
36
37
  end
data/lib/boletosimples.rb CHANGED
@@ -13,6 +13,8 @@ module BoletoSimples
13
13
  autoload :BankBilletAccount, 'boletosimples/resources/bank_billet_account'
14
14
  autoload :Event, 'boletosimples/resources/event'
15
15
  autoload :Customer, 'boletosimples/resources/customer'
16
+ autoload :CustomerSubscription, 'boletosimples/resources/customer_subscription'
17
+ autoload :Installment, 'boletosimples/resources/installment'
16
18
  autoload :Transaction, 'boletosimples/resources/transaction'
17
19
  autoload :Remittance, 'boletosimples/resources/remittance'
18
20
  autoload :Discharge, 'boletosimples/resources/discharge'
@@ -42,4 +44,4 @@ module BoletoSimples
42
44
 
43
45
  end
44
46
 
45
- BoletoSimples.configure
47
+ BoletoSimples.configure
@@ -60,7 +60,7 @@ module BoletoSimples
60
60
  end
61
61
 
62
62
  # Because Her set the api on the moment module is included we need to call use_api again, after changing the configuration.
63
- [BankBillet, BankBilletAccount, Customer, Transaction, Partner::User,
63
+ [BankBillet, BankBilletAccount, Customer, CustomerSubscription, Installment, Transaction, Partner::User,
64
64
  Webhook, Discharge, Remittance, WebhookDelivery, Event].each do |klass|
65
65
  klass.send(:use_api, Her::API.default_api)
66
66
  end
@@ -68,4 +68,4 @@ module BoletoSimples
68
68
 
69
69
  end
70
70
 
71
- end
71
+ end
@@ -0,0 +1,14 @@
1
+ module BoletoSimples
2
+ class CustomerSubscription < BaseModel
3
+
4
+ def next_charge
5
+ self.class.request(:_method => :post, :_path => self.class.build_request_path('customer_subscription_subscriptions/:id/next_charge', {self.class.primary_key => id})) do |parsed_data, response|
6
+ assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
7
+ @metadata = parsed_data[:metadata]
8
+ @response_errors = parsed_data[:errors]
9
+ @response = response
10
+ end
11
+ return @response.success?
12
+ end
13
+ end
14
+ end
@@ -1,4 +1,14 @@
1
1
  module BoletoSimples
2
2
  class Discharge < BaseModel
3
+
4
+ def pay_off
5
+ self.class.request(:_method => :put, :_path => self.class.build_request_path('discharges/:id/pay_off', {self.class.primary_key => id})) do |parsed_data, response|
6
+ assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
7
+ @metadata = parsed_data[:metadata]
8
+ @response_errors = parsed_data[:errors]
9
+ @response = response
10
+ end
11
+ return @response.success?
12
+ end
3
13
  end
4
14
  end
@@ -0,0 +1,4 @@
1
+ module BoletoSimples
2
+ class Installment < BaseModel
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module BoletoSimples
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -0,0 +1,60 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ # Before running this spec again, you need to set environment variable BOLETOSIMPLES_ACCESS_TOKEN
6
+ RSpec.describe BoletoSimples::CustomerSubscription do
7
+ before {
8
+ BoletoSimples.configure do |c|
9
+ c.application_id = nil
10
+ c.application_secret = nil
11
+ end
12
+ }
13
+ describe 'methods' do
14
+ before {
15
+ VCR.use_cassette('resources/customer_subscription/create/valid') do
16
+ @customer_subscription = BoletoSimples::CustomerSubscription.create({
17
+ customer_id: "11",
18
+ bank_billet_account_id: "12",
19
+ amount: "1.120,4",
20
+ cycle: "monthly",
21
+ description: "Hospedagem"
22
+ })
23
+ end
24
+ }
25
+ describe 'create' do
26
+ context 'valid parameters' do
27
+ subject { @customer_subscription }
28
+ it { expect(subject).to be_a_kind_of(BoletoSimples::CustomerSubscription) }
29
+ it { expect(subject.response_errors).to eq({}) }
30
+ it { expect(subject.attributes.keys).to match_array(["amount", "bank_billet_account_id", "created_at", "created_via_api", "customer_id", "cycle", "days_in_advance", "description", "end_at", "id", "instructions", "next_billing", "updated_at"]) }
31
+ end
32
+ context 'invalid parameters' do
33
+ context 'empty bank_billet' do
34
+ subject {
35
+ VCR.use_cassette('resources/customer_subscription/create/invalid_root') do
36
+ BoletoSimples::CustomerSubscription.create({})
37
+ end
38
+ }
39
+ it { expect(subject.response_errors).to eq({ :customer_subscription => ["não pode ficar em branco"] }) }
40
+ end
41
+ context 'invalid params' do
42
+ subject {
43
+ VCR.use_cassette('resources/customer_subscription/create/invalid_params') do
44
+ BoletoSimples::CustomerSubscription.create({ customer_id: '' })
45
+ end
46
+ }
47
+ it { expect(subject.response_errors).to eq({ :customer=>["não pode ficar em branco"], :bank_billet_account=>["não pode ficar em branco"], :amount=>["não pode ficar em branco"], :description=>["não pode ficar em branco"] }) }
48
+ end
49
+ end
50
+ end
51
+ describe 'find', vcr: { cassette_name: 'resources/customer_subscription/find' } do
52
+ subject { BoletoSimples::CustomerSubscription.find(@customer_subscription.id) }
53
+ it { expect(subject).to be_a_kind_of(BoletoSimples::CustomerSubscription) }
54
+ end
55
+ describe 'all', vcr: { cassette_name: 'resources/customer_subscription/all' } do
56
+ subject { BoletoSimples::CustomerSubscription.all }
57
+ it { expect(subject.first).to be_a_kind_of(BoletoSimples::CustomerSubscription) }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ # Before running this spec again, you need to set environment variable BOLETOSIMPLES_ACCESS_TOKEN
6
+ RSpec.describe BoletoSimples::Installment do
7
+ before {
8
+ BoletoSimples.configure do |c|
9
+ c.application_id = nil
10
+ c.application_secret = nil
11
+ end
12
+ }
13
+ describe 'methods' do
14
+ before {
15
+ VCR.use_cassette('resources/installment/create/valid') do
16
+ @installment = BoletoSimples::Installment.create({
17
+ customer_id: "11",
18
+ bank_billet_account_id: "12",
19
+ amount: "1.120,4",
20
+ cycle: "monthly",
21
+ start_at: "2016-09-15",
22
+ total: "3",
23
+ description: "Hospedagem"
24
+ })
25
+ end
26
+ }
27
+ describe 'create' do
28
+ context 'valid parameters' do
29
+ subject { @installment }
30
+ it { expect(subject).to be_a_kind_of(BoletoSimples::Installment) }
31
+ it { expect(subject.response_errors).to eq({}) }
32
+ it { expect(subject.attributes.keys).to match_array(["amount", "bank_billet_account_id", "created_at", "created_via_api", "customer_id", "cycle", "description", "end_at", "id", "instructions", "start_at", "status", "total", "updated_at"]) }
33
+ end
34
+ context 'invalid parameters' do
35
+ context 'empty bank_billet' do
36
+ subject {
37
+ VCR.use_cassette('resources/installment/create/invalid_root') do
38
+ BoletoSimples::Installment.create({})
39
+ end
40
+ }
41
+ it { expect(subject.response_errors).to eq({ :installment => ["não pode ficar em branco"] }) }
42
+ end
43
+ context 'invalid params' do
44
+ subject {
45
+ VCR.use_cassette('resources/installment/create/invalid_params') do
46
+ BoletoSimples::Installment.create({ person_name: '' })
47
+ end
48
+ }
49
+ it { expect(subject.response_errors).to eq({ :customer=>["não pode ficar em branco"], :bank_billet_account=>["não pode ficar em branco"], :cycle=>["não pode ficar em branco", "não está incluído na lista"], :total=>["não pode ficar em branco"], :start_at=>["não pode ficar em branco"], :description=>["não pode ficar em branco"], :amount=>["deve ser maior que 0"] }) }
50
+ end
51
+ end
52
+ end
53
+ describe 'find', vcr: { cassette_name: 'resources/installment/find' } do
54
+ subject { BoletoSimples::Installment.find(@installment.id) }
55
+ it { expect(subject).to be_a_kind_of(BoletoSimples::Installment) }
56
+ end
57
+ describe 'all', vcr: { cassette_name: 'resources/installment/all' } do
58
+ subject { BoletoSimples::Installment.all }
59
+ it { expect(subject.first).to be_a_kind_of(BoletoSimples::Installment) }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,83 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://sandbox.boletosimples.com.br/api/v1/customer_subscriptions?access_token=BOLETOSIMPLES_ACCESS_TOKEN
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - BoletoSimples Ruby Client v0.3.1 (contato@boletosimples.com.br)
12
+ Authorization:
13
+ - Token token="BOLETOSIMPLES_ACCESS_TOKEN"
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Connection:
24
+ - keep-alive
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Status:
30
+ - 200 OK
31
+ Cache-Control:
32
+ - must-revalidate, private, max-age=0
33
+ X-Ratelimit-Limit:
34
+ - '500'
35
+ Date:
36
+ - Mon, 15 Aug 2016 19:12:06 GMT
37
+ Strict-Transport-Security:
38
+ - max-age=631138519
39
+ X-Ratelimit-Remaining:
40
+ - '495'
41
+ Vary:
42
+ - Accept-Encoding
43
+ X-Permitted-Cross-Domain-Policies:
44
+ - none
45
+ X-Xss-Protection:
46
+ - 1; mode=block
47
+ X-Request-Id:
48
+ - 5c69fc71-b769-4fff-8c90-78735b4df6ad
49
+ Content-Security-Policy-Report-Only:
50
+ - 'default-src ''self''; child-src ''self'' www.googleadservices.com googleads.g.doubleclick.net
51
+ www.google.com; connect-src ws: wss: *.intercom.io ws.pusherapp.com hn.inspectlet.com
52
+ stats.pusher.com; font-src ''self'' fonts.googleapis.com fonts.gstatic.com
53
+ data:; img-src ''self'' https: data:; script-src ''self'' static.intercomcdn.com
54
+ cdn.inspectlet.com widget.intercom.io js.intercomcdn.com js.pusher.com stats.pusher.com
55
+ zapier.com www.google-analytics.com www.googleadservices.com i.kissmetrics.com
56
+ doug1izaerwt3.cloudfront.net app.popupdomination.com cdn.ywxi.net www.draw.io;
57
+ style-src ''self'' fonts.googleapis.com; report-uri https://boletosimples.report-uri.io/r/default/csp/reportOnly'
58
+ Total:
59
+ - '2'
60
+ X-Download-Options:
61
+ - noopen
62
+ Etag:
63
+ - W/"047508737376fc72cc83ff5ba90195f0"
64
+ X-Runtime:
65
+ - '0.037184'
66
+ X-Frame-Options:
67
+ - sameorigin
68
+ X-Content-Type-Options:
69
+ - nosniff
70
+ X-Rack-Cache:
71
+ - miss
72
+ X-Powered-By:
73
+ - Phusion Passenger 5.0.30
74
+ Server:
75
+ - nginx/1.10.1 + Phusion Passenger 5.0.30
76
+ Via:
77
+ - 1.1 vegur
78
+ body:
79
+ encoding: UTF-8
80
+ string: '[{"id":3,"amount":1120.4,"cycle":"monthly","next_billing":"2016-09-15","end_at":null,"instructions":null,"customer_id":11,"description":"Hospedagem","created_at":"2016-08-15","updated_at":"2016-08-15","created_via_api":true,"days_in_advance":7,"bank_billet_account_id":12},{"id":4,"amount":1120.4,"cycle":"monthly","next_billing":"2016-09-15","end_at":null,"instructions":null,"customer_id":11,"description":"Hospedagem","created_at":"2016-08-15","updated_at":"2016-08-15","created_via_api":true,"days_in_advance":7,"bank_billet_account_id":12}]'
81
+ http_version:
82
+ recorded_at: Mon, 15 Aug 2016 19:12:06 GMT
83
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,83 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sandbox.boletosimples.com.br/api/v1/customer_subscriptions?access_token=BOLETOSIMPLES_ACCESS_TOKEN
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"customer_subscription":{"customer_id":""}}'
9
+ headers:
10
+ User-Agent:
11
+ - BoletoSimples Ruby Client v0.3.1 (contato@boletosimples.com.br)
12
+ Authorization:
13
+ - Token token="BOLETOSIMPLES_ACCESS_TOKEN"
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 422
23
+ message: Unprocessable Entity
24
+ headers:
25
+ Connection:
26
+ - keep-alive
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Status:
32
+ - 422 Unprocessable Entity
33
+ Cache-Control:
34
+ - no-cache
35
+ X-Ratelimit-Limit:
36
+ - '500'
37
+ Date:
38
+ - Mon, 15 Aug 2016 19:12:05 GMT
39
+ Strict-Transport-Security:
40
+ - max-age=631138519
41
+ X-Ratelimit-Remaining:
42
+ - '497'
43
+ Vary:
44
+ - Accept-Encoding
45
+ X-Permitted-Cross-Domain-Policies:
46
+ - none
47
+ X-Xss-Protection:
48
+ - 1; mode=block
49
+ X-Request-Id:
50
+ - 4f6a7f8d-2994-4a6d-b7ae-fc2dd1aa083b
51
+ Content-Security-Policy-Report-Only:
52
+ - 'default-src ''self''; child-src ''self'' www.googleadservices.com googleads.g.doubleclick.net
53
+ www.google.com; connect-src ws: wss: *.intercom.io ws.pusherapp.com hn.inspectlet.com
54
+ stats.pusher.com; font-src ''self'' fonts.googleapis.com fonts.gstatic.com
55
+ data:; img-src ''self'' https: data:; script-src ''self'' static.intercomcdn.com
56
+ cdn.inspectlet.com widget.intercom.io js.intercomcdn.com js.pusher.com stats.pusher.com
57
+ zapier.com www.google-analytics.com www.googleadservices.com i.kissmetrics.com
58
+ doug1izaerwt3.cloudfront.net app.popupdomination.com cdn.ywxi.net www.draw.io;
59
+ style-src ''self'' fonts.googleapis.com; report-uri https://boletosimples.report-uri.io/r/default/csp/reportOnly'
60
+ X-Download-Options:
61
+ - noopen
62
+ X-Runtime:
63
+ - '0.028764'
64
+ X-Frame-Options:
65
+ - sameorigin
66
+ X-Content-Type-Options:
67
+ - nosniff
68
+ X-Rack-Cache:
69
+ - invalidate, pass
70
+ X-Powered-By:
71
+ - Phusion Passenger 5.0.30
72
+ Server:
73
+ - nginx/1.10.1 + Phusion Passenger 5.0.30
74
+ Via:
75
+ - 1.1 vegur
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"errors":{"customer":["não pode ficar em branco"],"bank_billet_account":["não
79
+ pode ficar em branco"],"amount":["não pode ficar em branco"],"description":["não
80
+ pode ficar em branco"]}}'
81
+ http_version:
82
+ recorded_at: Mon, 15 Aug 2016 19:12:05 GMT
83
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sandbox.boletosimples.com.br/api/v1/customer_subscriptions?access_token=BOLETOSIMPLES_ACCESS_TOKEN
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"customer_subscription":{}}'
9
+ headers:
10
+ User-Agent:
11
+ - BoletoSimples Ruby Client v0.3.1 (contato@boletosimples.com.br)
12
+ Authorization:
13
+ - Token token="BOLETOSIMPLES_ACCESS_TOKEN"
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 422
23
+ message: Unprocessable Entity
24
+ headers:
25
+ Connection:
26
+ - keep-alive
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Status:
32
+ - 422 Unprocessable Entity
33
+ Cache-Control:
34
+ - no-cache
35
+ X-Ratelimit-Limit:
36
+ - '500'
37
+ Date:
38
+ - Mon, 15 Aug 2016 19:12:06 GMT
39
+ Strict-Transport-Security:
40
+ - max-age=631138519
41
+ X-Ratelimit-Remaining:
42
+ - '496'
43
+ Vary:
44
+ - Accept-Encoding
45
+ X-Permitted-Cross-Domain-Policies:
46
+ - none
47
+ X-Xss-Protection:
48
+ - 1; mode=block
49
+ X-Request-Id:
50
+ - e6629d8d-71eb-4445-b92e-52ca340c868a
51
+ Content-Security-Policy-Report-Only:
52
+ - 'default-src ''self''; child-src ''self'' www.googleadservices.com googleads.g.doubleclick.net
53
+ www.google.com; connect-src ws: wss: *.intercom.io ws.pusherapp.com hn.inspectlet.com
54
+ stats.pusher.com; font-src ''self'' fonts.googleapis.com fonts.gstatic.com
55
+ data:; img-src ''self'' https: data:; script-src ''self'' static.intercomcdn.com
56
+ cdn.inspectlet.com widget.intercom.io js.intercomcdn.com js.pusher.com stats.pusher.com
57
+ zapier.com www.google-analytics.com www.googleadservices.com i.kissmetrics.com
58
+ doug1izaerwt3.cloudfront.net app.popupdomination.com cdn.ywxi.net www.draw.io;
59
+ style-src ''self'' fonts.googleapis.com; report-uri https://boletosimples.report-uri.io/r/default/csp/reportOnly'
60
+ X-Download-Options:
61
+ - noopen
62
+ X-Runtime:
63
+ - '0.020464'
64
+ X-Frame-Options:
65
+ - sameorigin
66
+ X-Content-Type-Options:
67
+ - nosniff
68
+ X-Rack-Cache:
69
+ - invalidate, pass
70
+ X-Powered-By:
71
+ - Phusion Passenger 5.0.30
72
+ Server:
73
+ - nginx/1.10.1 + Phusion Passenger 5.0.30
74
+ Via:
75
+ - 1.1 vegur
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"errors":{"customer_subscription":["não pode ficar em branco"]}}'
79
+ http_version:
80
+ recorded_at: Mon, 15 Aug 2016 19:12:06 GMT
81
+ recorded_with: VCR 2.9.3