vindi 0.0.2 → 0.0.7

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
- SHA1:
3
- metadata.gz: aa9ad99820c63edef8c56003e328dd221ce994cd
4
- data.tar.gz: 834423a9ffabfad33678cf29fae92cb371e4ede2
2
+ SHA256:
3
+ metadata.gz: 9f01bf9d6e3a22835cd557854ba2a872d8d93f00bac91eb39173c0d1a053eded
4
+ data.tar.gz: 55fca250dcb434eda27d0c622ebda23af2e297c78f670b1663e0771704a8aa5e
5
5
  SHA512:
6
- metadata.gz: b6d6f22cba50f50a2ca96eb6d99e78555c8699af0feafac40ab6eba87ca4bc2da665ee2bcd0d842df6a1ad6cd37dd0ed4c53cc7c3ba63c876f95db2412f05d8f
7
- data.tar.gz: b59bbdcaa255677a7d964a0bc57f0b24c42606031b2ca7051587d29d7720a0ec8c6b0c553bda78f62cdfcf120f6958559b30b5d608b2a53b9ade55cd0022fa01
6
+ metadata.gz: 1ba007ab34bb9d2e5df9806395eace7ffff91b7f2982ab48e878862f8eea39232d579d66af1ea660fe8e210c81fa914f7b12e1419cf866a4cd2d0037f9dbea26
7
+ data.tar.gz: 5e550b5914ce0ec3b191f058c56d7a88274d16a49f707a6b6a5c7a2467507e2f3ebf7d487de9a713f5f929cfe004d7d14fb98917c194cac7f7177cbbcf301504
data/README.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Vindi Ruby
2
2
 
3
+ [![Build Status](https://semaphoreci.com/api/v1/projects/48986e75-f1a3-4ca3-ae41-2d6cf64ac507/1512354/badge.svg)](https://semaphoreci.com/vindi/vindi-ruby)
4
+
5
+ ## Descrição
6
+
3
7
  Ruby toolkit para a [API de Recorrência][link-introducao-api] da [Vindi][link-vindi].
4
8
 
5
- [![Build Status](https://semaphoreci.com/api/v1/projects/48986e75-f1a3-4ca3-ae41-2d6cf64ac507/1512354/badge.svg)](https://semaphoreci.com/vindi/vindi-ruby)
9
+ ## Requisitos
10
+
11
+ * Ruby >=2.3;
12
+ * Certificado digital HTTPS assinado por uma entidade certificadora;
13
+ * Conta ativa na [Vindi](https://www.vindi.com.br).
6
14
 
7
15
  ## Instalação
8
16
 
@@ -10,11 +18,11 @@ Ruby toolkit para a [API de Recorrência][link-introducao-api] da [Vindi][link-v
10
18
  gem 'vindi'
11
19
  ```
12
20
 
13
- And then execute:
21
+ Então execute:
14
22
 
15
23
  $ bundle
16
24
 
17
- Or install it yourself as:
25
+ Ou instale você mesmo:
18
26
 
19
27
  $ gem install vindi
20
28
 
@@ -22,11 +30,24 @@ Or install it yourself as:
22
30
  Os métodos da API estão disponíveis atraves dos métodos da instancia de um cliente
23
31
 
24
32
  ```ruby
25
- client = Vindi::Client.new(key: 'VINDI_KEY')
26
- ```
33
+ client = Vindi::Client.new(key: '<sua_vindi_api_key>')
34
+ ```
35
+
36
+ Para testar no ambiente Sandbox, use o endpoint da API para efetuar requisições:
37
+
38
+ ```ruby
39
+ client = Vindi::Client.new(key: '<sua_vindi_api_key>', api_endpoint: 'https://sandbox-app.vindi.com.br/api/v1')
40
+ ```
41
+
42
+ Caso prefira utilizar variáveis de ambiente para prover credenciais de acesso:
43
+
44
+ ```
45
+ export VINDI_KEY="<sua_vindi_api_key>"
46
+ export VINDI_API_ENDPOINT="https://sandbox-app.vindi.com.br/api/v1"
47
+ ```
27
48
 
28
49
  ### Consumindo recursos
29
- Os recursos são fornecidos através do objeto de retono e os campos retornados podem ser acessados pela notação de attributos de um Hash
50
+ Os recursos são fornecidos através do objeto de retorno e os campos retornados podem ser acessados pela notação de attributos de um Hash
30
51
 
31
52
  ```ruby
32
53
  # Listando planos de um lojista
@@ -43,7 +64,7 @@ Os recursos são fornecidos através do objeto de retono e os campos retornados
43
64
 
44
65
  # Criando um plano
45
66
  client.create_plan({name: 'My new plan', interval: 'months', interval_count: 1, billing_trigger_type: 'beginning_of_period'})
46
- ```
67
+ ```
47
68
 
48
69
  ### Acessando respostas HTTP
49
70
 
@@ -51,7 +72,7 @@ Os recursos são fornecidos através do objeto de retono e os campos retornados
51
72
  client.list_plans
52
73
  response = client.last_response
53
74
  status = response.status
54
- ```
75
+ ```
55
76
 
56
77
  ## Dúvidas
57
78
  Caso necessite de informações sobre a plataforma ou API, por favor acesse o [Atendimento Vindi](http://atendimento.vindi.com.br/hc/pt-br).
@@ -1,6 +1,7 @@
1
1
  module Vindi
2
2
  # Custom error class for rescuing from all Vindi errors
3
3
  class Error < StandardError
4
+ attr_accessor :status_code
4
5
 
5
6
  # Raised when Vindi returns a 4xx HTTP status code
6
7
  ClientError = Class.new(self)
@@ -29,6 +30,9 @@ module Vindi
29
30
  # Raised when Vindi returns a 5xx HTTP status code
30
31
  ServerError = Class.new(self)
31
32
 
33
+ # Raised when Vindi returns the HTTP status code 500
34
+ InternalServerError = Class.new(ServerError)
35
+
32
36
  # Raised when Vindi returns the HTTP status code 502
33
37
  BadGateway = Class.new(ServerError)
34
38
 
@@ -68,10 +72,11 @@ module Vindi
68
72
  end
69
73
 
70
74
  def build_error_message(response)
71
- return if response.nil?
75
+ return unless response&.body
76
+
77
+ self.status_code = response.status
72
78
 
73
- message = "#{response[:method].to_s.upcase} "
74
- message
79
+ response.body
75
80
  end
76
81
  end
77
82
  end
@@ -22,6 +22,7 @@ module Vindi
22
22
  include Vindi::Rest::Invoice
23
23
  include Vindi::Rest::Message
24
24
  include Vindi::Rest::ImportBatch
25
+ include Vindi::Rest::ExportBatch
25
26
  include Vindi::Rest::Notification
26
27
  include Vindi::Rest::Issue
27
28
  include Vindi::Rest::Merchant
@@ -11,7 +11,8 @@ module Vindi
11
11
  def list_charges(options = {})
12
12
  get('charges', options)[:charges]
13
13
  end
14
-
14
+
15
+
15
16
  # Get a single charge from a merchant
16
17
  #
17
18
  # @param charge_id [Integer] ID of the charge
@@ -89,6 +90,19 @@ module Vindi
89
90
  def delete_charge(charge_id, options = {})
90
91
  delete("charges/#{charge_id}", options)[:charge]
91
92
  end
93
+
94
+
95
+ # Capture a charge from merchant vindi
96
+ #
97
+ # @params charge_id [Integer] ID of the charge
98
+ # @option options [Hash] :options charge attributes
99
+ #
100
+ # @see https://vindi.github.io/api-docs/dist/#!/charges/POST_version_charges_id_capture_format
101
+ # @example Capture charge #2
102
+ # client.capture_charge(2)
103
+ def capture_charge(charge_id, options = {})
104
+ post("charges/#{charge_id}/capture", options)[:charge]
105
+ end
92
106
  end
93
107
  end
94
108
  end
@@ -11,7 +11,7 @@ module Vindi
11
11
  def list_customers(options = {})
12
12
  get('customers', options)[:customers]
13
13
  end
14
-
14
+
15
15
  # Get a single customer from a merchant
16
16
  #
17
17
  # @param customer_id [Integer] ID of the customer
@@ -24,9 +24,9 @@ module Vindi
24
24
  end
25
25
 
26
26
  # Create a customer for a merchant vindi
27
- #
27
+ #
28
28
  # @option options [Hash] :options customer attributes
29
- # @see https://vindi.github.io/api-docs/dist/#!/customers/POST_version_customers_format
29
+ # @see https://vindi.github.io/api-docs/dist/#!/customers/POST_version_customers_format
30
30
  # @return [Hash] The customer created
31
31
  # @example Create a customer for a merchant vindi
32
32
  # client.create_customer(name: 'John Doe', email: 'john.doe@mail.com')
@@ -56,6 +56,19 @@ module Vindi
56
56
  def delete_customer(customer_id, options = {})
57
57
  delete("customers/#{customer_id}", options)[:customer]
58
58
  end
59
+
60
+
61
+ # Unarchive a customer from merchant vindi
62
+ #
63
+ # @params customer_id [Integer] ID of the customer
64
+ # @option options [Hash] :options customer attributes
65
+ #
66
+ # @see https://vindi.github.io/api-docs/dist/#!/customers/POST_version_customers_id_unarchive_format
67
+ # @example Unarchive customer #2
68
+ # client.unarchive_customer(2)
69
+ def unarchive_customer(customer_id, options = {})
70
+ post("customers/#{customer_id}/unarchive", options)[:customer]
71
+ end
59
72
  end
60
73
  end
61
74
  end
@@ -0,0 +1,52 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the export_batches API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/export_batches
6
+ module ExportBatch
7
+
8
+ # List export batches for the authenticate user
9
+ # @option options [Integer] :page (1) Page number.
10
+ # @option options [Integer] :merchant Merchant account
11
+ # @return [Array<Hash>] A list of export batches for a merchant.
12
+ # @example Get all export batches from merchant vindi
13
+ def list_export_batches(options = {})
14
+ get('export_batches', options)[:export_batches]
15
+ end
16
+
17
+ # Get a single export batch from a merchant
18
+ #
19
+ # @param export_batch_id [Integer] ID of the export batch
20
+ # @return [Hash] The export batch you requested, if it exists
21
+ # @see https://vindi.github.io/api-docs/dist/#!/export_batches/GET_version_export_batches_id_format
22
+ # @example Get export batch #154 from vindi
23
+ # client.export_batch(154)
24
+ def export_batch(export_batch_id, options = {})
25
+ get("export_batches/#{export_batch_id}", options)[:export_batch]
26
+ end
27
+
28
+ # Create an export batch for a merchant vindi
29
+ #
30
+ # @option options [Hash] :options export_batch attributes
31
+ # @see https://vindi.github.io/api-docs/dist/#!/export_batches/POST_version_export_batches_format
32
+ # @return [Hash] The export batch created
33
+ # @example Create an export batch for a merchant vindi
34
+ # client.create_export_batch({ "payment_method_code": 2, "payment_company_code": "itau" })
35
+ def create_export_batch(options = {})
36
+ post('export_batches', options)[:export_batch]
37
+ end
38
+
39
+
40
+ # Approve an export batch for a merchant vindi
41
+ #
42
+ # @option options [Hash] :options export_batch attributes
43
+ # @see https://vindi.github.io/api-docs/dist/#!/export_batches/POST_version_export_batches_id_approve_format
44
+ # @return [Hash] The export batch approved
45
+ # @example Approve an export batch for a merchant vindi
46
+ # client.approve_export_batch(2)
47
+ def approve_export_batch(export_batch_id, options = {})
48
+ post("export_batches/#{export_batch_id}/approve", options)[:export_batch]
49
+ end
50
+ end
51
+ end
52
+ end
@@ -5,7 +5,7 @@ module Vindi
5
5
  # @see https://vindi.github.io/api-docs/dist/#!/import_batches
6
6
  module ImportBatch
7
7
 
8
- # List import_batchs for the authenticate user
8
+ # List import_batches for the authenticate user
9
9
  # @option options [Integer] :page (1) Page number.
10
10
  # @option options [Integer] :merchant Merchant account
11
11
  # @return [Array<Hash>] A list of imported batches for a merchant.
@@ -47,6 +47,18 @@ module Vindi
47
47
  def update_period(period_id, options = {})
48
48
  put("periods/#{period_id}", options)[:period]
49
49
  end
50
+
51
+ # List period usages
52
+ #
53
+ # @params period_id [Integer] ID of the period
54
+ # @option options [Integer] :page (1) Page number.
55
+ # @return [Array<Hash>] A list of usages for a period.
56
+ # @see https://vindi.github.io/api-docs/dist/#/periods/getV1PeriodsIdUsages
57
+ # @example List period usages
58
+ # client.list_period_usages(2)
59
+ def list_period_usages(period_id, options = {})
60
+ get("periods/#{period_id}/usages", options)[:usages]
61
+ end
50
62
  end
51
63
  end
52
64
  end
@@ -80,6 +80,16 @@ module Vindi
80
80
  def delete_subscription(subscription_id, options = {})
81
81
  delete("subscriptions/#{subscription_id}", options)[:subscription]
82
82
  end
83
+
84
+ # List product items for a subscription
85
+ #
86
+ # @params subscription_id
87
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/GET_version_subscriptions_id_product_items_format
88
+ # @example List subscription product items #2
89
+ # client.list_subscription_product_items(2)
90
+ def list_subscription_product_items(subscription_id, options = {})
91
+ get("subscriptions/#{subscription_id}/product_items", options)[:product_items]
92
+ end
83
93
  end
84
94
  end
85
95
  end
@@ -1,3 +1,3 @@
1
1
  module Vindi
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -15,7 +15,8 @@ Gem::Specification.new do |spec|
15
15
  spec.files += Dir.glob("lib/**/*.rb")
16
16
  spec.require_paths = ["lib"]
17
17
 
18
- spec.add_dependency 'faraday', '~> 0.13.1'
19
- spec.add_development_dependency "bundler", "~> 1.15"
18
+
19
+ spec.add_dependency 'faraday', '~> 0.13'
20
+ spec.add_development_dependency "bundler"
20
21
  spec.add_development_dependency "rake", "~> 10.0"
21
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vindi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vindi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.1
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.13.1
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.15'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.15'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +74,7 @@ files:
74
74
  - lib/vindi/rest/charge.rb
75
75
  - lib/vindi/rest/customer.rb
76
76
  - lib/vindi/rest/discount.rb
77
+ - lib/vindi/rest/export_batch.rb
77
78
  - lib/vindi/rest/import_batch.rb
78
79
  - lib/vindi/rest/invoice.rb
79
80
  - lib/vindi/rest/issue.rb
@@ -113,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.6.13
117
+ rubygems_version: 3.1.2
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Ruby toolkit for working with the Vindi API