boletosimples 0.0.7 → 0.1.1

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/README.md +156 -3
  4. data/boletosimples.gemspec +9 -9
  5. data/lib/boletosimples.rb +38 -4
  6. data/lib/boletosimples/configuration.rb +69 -0
  7. data/lib/boletosimples/extra.rb +8 -0
  8. data/lib/boletosimples/last_request.rb +43 -0
  9. data/lib/boletosimples/middlewares/last_request.rb +9 -0
  10. data/lib/boletosimples/middlewares/raise_error.rb +11 -0
  11. data/lib/boletosimples/middlewares/user_agent.rb +10 -0
  12. data/lib/boletosimples/resources/bank_billet.rb +13 -0
  13. data/lib/boletosimples/resources/base_model.rb +8 -0
  14. data/lib/boletosimples/resources/customer.rb +4 -0
  15. data/lib/boletosimples/resources/partner/user.rb +7 -0
  16. data/lib/boletosimples/resources/transaction.rb +4 -0
  17. data/lib/boletosimples/response_error.rb +43 -0
  18. data/lib/boletosimples/version.rb +1 -1
  19. data/spec/boletosimples/configuration_spec.rb +84 -0
  20. data/spec/boletosimples/extra_spec.rb +31 -0
  21. data/spec/boletosimples/last_request_spec.rb +34 -0
  22. data/spec/boletosimples/resources/bank_billet_spec.rb +75 -0
  23. data/spec/boletosimples/resources/customer_spec.rb +66 -0
  24. data/spec/boletosimples/resources/partner/user_spec.rb +19 -0
  25. data/spec/boletosimples/resources/transactions_spec.rb +17 -0
  26. data/spec/fixtures/vcr_cassettes/configuration/client_credentials/invalid.yml +64 -0
  27. data/spec/fixtures/vcr_cassettes/configuration/client_credentials/valid.yml +56 -0
  28. data/spec/fixtures/vcr_cassettes/extra/userinfo/authenticated.yml +58 -0
  29. data/spec/fixtures/vcr_cassettes/extra/userinfo/not_authenticated.yml +54 -0
  30. data/spec/fixtures/vcr_cassettes/last_request/bank_billets.yml +129 -0
  31. data/spec/fixtures/vcr_cassettes/last_request/userinfo.yml +58 -0
  32. data/spec/fixtures/vcr_cassettes/resources/bank_billet/all.yml +132 -0
  33. data/spec/fixtures/vcr_cassettes/resources/bank_billet/cancel.yml +125 -0
  34. data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/invalid_params.yml +61 -0
  35. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_cancel_bank_billet/already_canceled.yml → resources/bank_billet/create/invalid_root.yml} +24 -24
  36. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_create_bank_billet/with_valid_data.yml → resources/bank_billet/create/valid.yml} +32 -28
  37. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_bank_billet/existing_bank_billet.yml → resources/bank_billet/find.yml} +30 -28
  38. data/spec/fixtures/vcr_cassettes/resources/customer/all.yml +72 -0
  39. data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_params.yml +59 -0
  40. data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_root.yml +58 -0
  41. data/spec/fixtures/vcr_cassettes/{BoletoSimples_Client/_create_customer/with_valid_data.yml → resources/customer/create/valid.yml} +30 -26
  42. data/spec/fixtures/vcr_cassettes/resources/customer/find.yml +59 -0
  43. data/spec/fixtures/vcr_cassettes/resources/partner/user/create.yml +60 -0
  44. data/spec/fixtures/vcr_cassettes/resources/transaction/all.yml +62 -0
  45. data/spec/spec_helper.rb +10 -0
  46. data/spec/support/vcr.rb +8 -0
  47. metadata +97 -80
  48. data/example/access_token_example.rb +0 -79
  49. data/example/oauth_example.rb +0 -126
  50. data/lib/boletosimples/client.rb +0 -100
  51. data/lib/boletosimples/oauth_client.rb +0 -74
  52. data/spec/boletosimples/client_spec.rb +0 -415
  53. data/spec/boletosimples/oauth_client_spec.rb +0 -17
  54. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_bank_billet/not_found.yml +0 -44
  55. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_bank_billets.yml +0 -63
  56. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_cancel_bank_billet/with_invalid_bank_billet.yml +0 -54
  57. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_cancel_bank_billet/with_valid_bank_billet.yml +0 -71
  58. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_create_bank_billet/with_invalid_data.yml +0 -64
  59. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_create_customer/with_invalid_data.yml +0 -59
  60. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_customer/existing_customer.yml +0 -57
  61. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_customer/not_found.yml +0 -58
  62. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_customers.yml +0 -59
  63. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_transactions.yml +0 -67
  64. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/with_authentication.yml +0 -56
  65. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/with_authentication/.yml +0 -56
  66. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/without_authentication.yml +0 -54
  67. data/spec/fixtures/vcr_cassettes/BoletoSimples_Client/_userinfo/without_authentication/.yml +0 -54
  68. data/spec/fixtures/vcr_cassettes/BoletoSimples_OAuthClient/_userinfo/without_authentication/.yml +0 -62
@@ -1,59 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/customers?access_token=9e616874dbf0674ace28170a748c9258ac1f0f87e0a544441ebffe976645bc09
6
- body:
7
- encoding: UTF-8
8
- string: '{"page":1}'
9
- headers:
10
- Content-Type:
11
- - application/json
12
- User-Agent:
13
- - Meu e-Commerce (meuecommerce@example.com)
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Server:
20
- - Cowboy
21
- Connection:
22
- - close
23
- Date:
24
- - Fri, 24 Oct 2014 18:26:06 GMT
25
- Status:
26
- - 200 OK
27
- Strict-Transport-Security:
28
- - max-age=2592000
29
- X-Frame-Options:
30
- - SAMEORIGIN
31
- X-Xss-Protection:
32
- - 1; mode=block
33
- X-Content-Type-Options:
34
- - nosniff
35
- Total:
36
- - '1'
37
- Content-Type:
38
- - application/json; charset=utf-8
39
- Etag:
40
- - '"f63a901ac28c3fb92064b5264897384e"'
41
- Cache-Control:
42
- - max-age=0, private, must-revalidate
43
- X-Request-Id:
44
- - 0f30030a-efc3-41f8-9e9c-275efc32fdb5
45
- X-Ratelimit-Limit:
46
- - '500'
47
- X-Ratelimit-Remaining:
48
- - '499'
49
- X-Runtime:
50
- - '1.722992'
51
- Via:
52
- - 1.1 vegur
53
- body:
54
- encoding: UTF-8
55
- string: '[{"id":32,"city_name":"Rio de Janeiro","person_name":"Joao da Silva","address":"Rua
56
- quinhentos","address_complement":"Sala 4","address_number":"111","mobile_number":null,"cnpj_cpf":"012.345.678-90","email":"cliente@bom.com","neighborhood":"bairro","person_type":"individual","phone_number":"2112123434","zipcode":"12312-123","mobile_local_code":null,"state":"RJ"}]'
57
- http_version:
58
- recorded_at: Fri, 24 Oct 2014 18:26:06 GMT
59
- recorded_with: VCR 2.9.3
@@ -1,67 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/transactions?access_token=9e616874dbf0674ace28170a748c9258ac1f0f87e0a544441ebffe976645bc09
6
- body:
7
- encoding: UTF-8
8
- string: '{"page":1}'
9
- headers:
10
- Content-Type:
11
- - application/json
12
- User-Agent:
13
- - Meu e-Commerce (meuecommerce@example.com)
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Server:
20
- - Cowboy
21
- Connection:
22
- - close
23
- Date:
24
- - Mon, 03 Nov 2014 22:35:47 GMT
25
- Status:
26
- - 200 OK
27
- Strict-Transport-Security:
28
- - max-age=2592000
29
- X-Frame-Options:
30
- - SAMEORIGIN
31
- X-Xss-Protection:
32
- - 1; mode=block
33
- X-Content-Type-Options:
34
- - nosniff
35
- Total:
36
- - '2'
37
- Content-Type:
38
- - application/json; charset=utf-8
39
- Etag:
40
- - '"44e7beba54834116cc3eb1cbfc5c0b89"'
41
- Cache-Control:
42
- - max-age=0, private, must-revalidate
43
- X-Request-Id:
44
- - 9520fe3c-9f4d-4bab-ad35-3ada0fff892a
45
- X-Ratelimit-Limit:
46
- - '500'
47
- X-Ratelimit-Remaining:
48
- - '499'
49
- X-Runtime:
50
- - '0.073431'
51
- Via:
52
- - 1.1 vegur
53
- body:
54
- encoding: ASCII-8BIT
55
- string: !binary |-
56
- W3siaWQiOjE1LCJhbW91bnQiOjkuMDEsImNyZWF0ZWRfYXQiOiIyMDE0LTEx
57
- LTAzIiwiZGVzY3JpcHRpb24iOiJCb2xldG8gQmFuY8OhcmlvIDExMyIsImtp
58
- bmQiOiJjcmVkaXQiLCJwcm9jZXNzZWRfYXQiOm51bGwsInNlbnRfYXQiOm51
59
- bGwsInN0YXR1cyI6InVucHJvY2Vzc2VkIiwiY3JlZGl0X2F0IjoiMjAxNC0x
60
- MS0wNiJ9LHsiaWQiOjE2LCJhbW91bnQiOi01LjAsImNyZWF0ZWRfYXQiOiIy
61
- MDE0LTExLTAzIiwiZGVzY3JpcHRpb24iOiJCb2xldG8gQmFuY8OhcmlvIDEx
62
- MyIsImtpbmQiOiJmZWUiLCJwcm9jZXNzZWRfYXQiOm51bGwsInNlbnRfYXQi
63
- Om51bGwsInN0YXR1cyI6InVucHJvY2Vzc2VkIiwiY3JlZGl0X2F0IjoiMjAx
64
- NC0xMS0wNiJ9XQ==
65
- http_version:
66
- recorded_at: Mon, 03 Nov 2014 22:35:47 GMT
67
- recorded_with: VCR 2.9.3
@@ -1,56 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/userinfo?access_token=9e616874dbf0674ace28170a748c9258ac1f0f87e0a544441ebffe976645bc09
6
- body:
7
- encoding: UTF-8
8
- string: "{}"
9
- headers:
10
- Content-Type:
11
- - application/json
12
- User-Agent:
13
- - Meu e-Commerce (meuecommerce@example.com)
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Server:
20
- - Cowboy
21
- Connection:
22
- - close
23
- Date:
24
- - Fri, 24 Oct 2014 17:15:09 GMT
25
- Status:
26
- - 200 OK
27
- Strict-Transport-Security:
28
- - max-age=2592000
29
- X-Frame-Options:
30
- - SAMEORIGIN
31
- X-Xss-Protection:
32
- - 1; mode=block
33
- X-Content-Type-Options:
34
- - nosniff
35
- Content-Type:
36
- - application/json; charset=utf-8
37
- Etag:
38
- - '"a5e53c2911f6654ee16b5d63fc3fa120"'
39
- Cache-Control:
40
- - max-age=0, private, must-revalidate
41
- X-Request-Id:
42
- - 43370077-7a00-4f85-a655-3cf584d21e98
43
- X-Ratelimit-Limit:
44
- - '500'
45
- X-Ratelimit-Remaining:
46
- - '499'
47
- X-Runtime:
48
- - '0.059536'
49
- Via:
50
- - 1.1 vegur
51
- body:
52
- encoding: UTF-8
53
- string: '{"id":38,"login_url":"https://sandbox.boletosimples.com.br/welcome?email=marciojunior1991%40gmail.com\u0026token=Z94HQ9Uzn2Cc1gzp9PWG","email":"marciojunior1991@gmail.com","account_type":null,"first_name":null,"middle_name":null,"last_name":null,"full_name":null,"cpf":null,"date_of_birth":null,"mother_name":null,"father_name":null,"account_level":2,"phone_number":null,"address_street_name":null,"address_number":null,"address_complement":null,"address_neighborhood":null,"address_postal_code":null,"address_city_name":null,"address_state":null,"business_name":null,"business_cnpj":null,"business_legal_name":null}'
54
- http_version:
55
- recorded_at: Fri, 24 Oct 2014 17:15:09 GMT
56
- recorded_with: VCR 2.9.3
@@ -1,56 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/userinfo?access_token=9e616874dbf0674ace28170a748c9258ac1f0f87e0a544441ebffe976645bc09
6
- body:
7
- encoding: UTF-8
8
- string: "{}"
9
- headers:
10
- Content-Type:
11
- - application/json
12
- User-Agent:
13
- - Meu e-Commerce (meuecommerce@example.com)
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Server:
20
- - Cowboy
21
- Connection:
22
- - close
23
- Date:
24
- - Fri, 24 Oct 2014 17:09:25 GMT
25
- Status:
26
- - 200 OK
27
- Strict-Transport-Security:
28
- - max-age=2592000
29
- X-Frame-Options:
30
- - SAMEORIGIN
31
- X-Xss-Protection:
32
- - 1; mode=block
33
- X-Content-Type-Options:
34
- - nosniff
35
- Content-Type:
36
- - application/json; charset=utf-8
37
- Etag:
38
- - '"a5e53c2911f6654ee16b5d63fc3fa120"'
39
- Cache-Control:
40
- - max-age=0, private, must-revalidate
41
- X-Request-Id:
42
- - 8024d2e8-0c30-40a4-97e7-3b657eceed9f
43
- X-Ratelimit-Limit:
44
- - '500'
45
- X-Ratelimit-Remaining:
46
- - '499'
47
- X-Runtime:
48
- - '0.102692'
49
- Via:
50
- - 1.1 vegur
51
- body:
52
- encoding: UTF-8
53
- string: '{"id":38,"login_url":"https://sandbox.boletosimples.com.br/welcome?email=marciojunior1991%40gmail.com\u0026token=Z94HQ9Uzn2Cc1gzp9PWG","email":"marciojunior1991@gmail.com","account_type":null,"first_name":null,"middle_name":null,"last_name":null,"full_name":null,"cpf":null,"date_of_birth":null,"mother_name":null,"father_name":null,"account_level":2,"phone_number":null,"address_street_name":null,"address_number":null,"address_complement":null,"address_neighborhood":null,"address_postal_code":null,"address_city_name":null,"address_state":null,"business_name":null,"business_cnpj":null,"business_legal_name":null}'
54
- http_version:
55
- recorded_at: Fri, 24 Oct 2014 17:09:25 GMT
56
- recorded_with: VCR 2.9.3
@@ -1,54 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/userinfo?access_token=
6
- body:
7
- encoding: UTF-8
8
- string: "{}"
9
- headers:
10
- Content-Type:
11
- - application/json
12
- User-Agent:
13
- - Meu e-Commerce (meuecommerce@example.com)
14
- response:
15
- status:
16
- code: 401
17
- message: Unauthorized
18
- headers:
19
- Server:
20
- - Cowboy
21
- Connection:
22
- - close
23
- Date:
24
- - Fri, 24 Oct 2014 16:53:01 GMT
25
- Status:
26
- - 401 Unauthorized
27
- Strict-Transport-Security:
28
- - max-age=2592000
29
- X-Frame-Options:
30
- - SAMEORIGIN
31
- X-Xss-Protection:
32
- - 1; mode=block
33
- X-Content-Type-Options:
34
- - nosniff
35
- Www-Authenticate:
36
- - Basic realm="Boleto Simples"
37
- Content-Type:
38
- - application/json; charset=utf-8
39
- Cache-Control:
40
- - no-cache
41
- X-Request-Id:
42
- - 11e5d0ee-1ecd-4e0f-9d91-6bd3ae9e811d
43
- X-Runtime:
44
- - '0.211845'
45
- Via:
46
- - 1.1 vegur
47
- body:
48
- encoding: ASCII-8BIT
49
- string: !binary |-
50
- eyJlcnJvciI6IlZvY8OqIHByZWNpc2Egc2UgbG9nYXIgb3UgcmVnaXN0cmFy
51
- IGFudGVzIGRlIHByb3NzZWd1aXIuIn0=
52
- http_version:
53
- recorded_at: Fri, 24 Oct 2014 16:53:01 GMT
54
- recorded_with: VCR 2.9.3
@@ -1,54 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/userinfo?access_token=
6
- body:
7
- encoding: UTF-8
8
- string: "{}"
9
- headers:
10
- Content-Type:
11
- - application/json
12
- User-Agent:
13
- - Meu e-Commerce (meuecommerce@example.com)
14
- response:
15
- status:
16
- code: 401
17
- message: Unauthorized
18
- headers:
19
- Server:
20
- - Cowboy
21
- Connection:
22
- - close
23
- Date:
24
- - Fri, 24 Oct 2014 17:15:08 GMT
25
- Status:
26
- - 401 Unauthorized
27
- Strict-Transport-Security:
28
- - max-age=2592000
29
- X-Frame-Options:
30
- - SAMEORIGIN
31
- X-Xss-Protection:
32
- - 1; mode=block
33
- X-Content-Type-Options:
34
- - nosniff
35
- Www-Authenticate:
36
- - Basic realm="Boleto Simples"
37
- Content-Type:
38
- - application/json; charset=utf-8
39
- Cache-Control:
40
- - no-cache
41
- X-Request-Id:
42
- - 91a925ba-63da-4a1a-ba8a-9e790f77a81a
43
- X-Runtime:
44
- - '0.019146'
45
- Via:
46
- - 1.1 vegur
47
- body:
48
- encoding: ASCII-8BIT
49
- string: !binary |-
50
- eyJlcnJvciI6IlZvY8OqIHByZWNpc2Egc2UgbG9nYXIgb3UgcmVnaXN0cmFy
51
- IGFudGVzIGRlIHByb3NzZWd1aXIuIn0=
52
- http_version:
53
- recorded_at: Fri, 24 Oct 2014 17:15:08 GMT
54
- recorded_with: VCR 2.9.3
@@ -1,62 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://sandbox.boletosimples.com.br/api/v1/userinfo
6
- body:
7
- encoding: UTF-8
8
- string: "{}"
9
- headers:
10
- User-Agent:
11
- - Meu e-Commerce (meuecommerce@example.com)
12
- Accept-Charset:
13
- - UTF-8
14
- Content-Type:
15
- - application/json
16
- Authorization:
17
- - Bearer invalid-token
18
- Accept-Encoding:
19
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
- Accept:
21
- - "*/*"
22
- response:
23
- status:
24
- code: 401
25
- message: Unauthorized
26
- headers:
27
- Server:
28
- - Cowboy
29
- Connection:
30
- - close
31
- Date:
32
- - Fri, 24 Oct 2014 16:53:02 GMT
33
- Status:
34
- - 401 Unauthorized
35
- Strict-Transport-Security:
36
- - max-age=2592000
37
- X-Frame-Options:
38
- - SAMEORIGIN
39
- X-Xss-Protection:
40
- - 1; mode=block
41
- X-Content-Type-Options:
42
- - nosniff
43
- Www-Authenticate:
44
- - Basic realm="Boleto Simples"
45
- Content-Type:
46
- - application/json; charset=utf-8
47
- Cache-Control:
48
- - no-cache
49
- X-Request-Id:
50
- - d23b7940-c389-45f4-a468-ec8d488862c8
51
- X-Runtime:
52
- - '0.081793'
53
- Via:
54
- - 1.1 vegur
55
- body:
56
- encoding: ASCII-8BIT
57
- string: !binary |-
58
- eyJlcnJvciI6IlZvY8OqIHByZWNpc2Egc2UgbG9nYXIgb3UgcmVnaXN0cmFy
59
- IGFudGVzIGRlIHByb3NzZWd1aXIuIn0=
60
- http_version:
61
- recorded_at: Fri, 24 Oct 2014 16:53:02 GMT
62
- recorded_with: VCR 2.9.3