getnet_api 0.1.2 → 1.0.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: dc8a4b6dee92d375bbc43cc83367c0573d842a48
4
- data.tar.gz: b64f13878e6462d61e7a1dade6a0e55d156a4bc2
3
+ metadata.gz: c32b84f0cc282c466eb9eff837a770e9f893d94f
4
+ data.tar.gz: ef83916d2cefdd177693703f3f127fdb6f3f7079
5
5
  SHA512:
6
- metadata.gz: b1f9fe4599f2389c34c46cbc6528cbc168524f2db5c7a7100c3d5e8db298097cf1014cec7dc4e1d7aa1c1ecea3403c25dca436c305403ff5ecfbab8c5cff5fad
7
- data.tar.gz: 54811bf2cc8d876a2302cb380e6b704c5a1d9002258a023ad157057065c8e10a8e9419f368d26055a89895adc5ecd8dc58f6f8fd2be26c59630942cd1f3e71dd
6
+ metadata.gz: a9e3b36d02e1f3907be1dc80f1f0f64e116fa9671bbe71bc14db34ede69cc5781a6c98c970cb83f7d32ae1577a951af50e727c5752955a6af48500935854b219
7
+ data.tar.gz: be29417634b753bf4ed3b79768626b2814b1cfc613511dad0f3920a2c2ffe1395f6ec5bbb8850b40dcecbe0c38fa1cf633fe6ae8daab191faad074879f1bb431
@@ -0,0 +1,54 @@
1
+ module GetnetApi
2
+ class PaymentCancel < Base
3
+ # payment_id
4
+ # string <= 36 characters Required
5
+ # ID do pagamento via cartão de crédito
6
+ attr_accessor :payment_id
7
+
8
+ # cancel_amount
9
+ # interger Required
10
+ # Valor do pagamento em centavos
11
+ attr_accessor :cancel_amount
12
+
13
+ # cancel_custom_key
14
+ # string <= 32 characters
15
+ # Chave do cliente utilizada para identificar uma solicitação de cancelamento.
16
+ attr_accessor :cancel_custom_key
17
+
18
+ # Validações do Rails 3
19
+ include ActiveModel::Validations
20
+
21
+ validates :amount, length: { maximum: 3 }
22
+
23
+ def initialize campos={}
24
+ campos.each do |campo, valor|
25
+ if GetnetApi::PaymentCancel.public_instance_methods.include? "#{campo}=".to_sym
26
+ send "#{campo}=", valor
27
+ end
28
+ end
29
+ end
30
+
31
+ # Montar o Hash de dados do usuario no padrão utilizado pela Getnet
32
+ def to_request
33
+ pay_cancel = {
34
+ payment_id: self.payment_id,
35
+ cancel_amount: self.cancel_amount,
36
+ cancel_custom_key: self.cancel_custom_key
37
+ }
38
+ end
39
+
40
+ # a = GetnetApi::PaymentCancel.create cancelamento_pagamento
41
+ def self.create payment_cancel
42
+ hash = payment_cancel.to_request
43
+
44
+ response = self.build_request self.endpoint, "post", hash
45
+
46
+ return JSON.parse(response.read_body)
47
+ end
48
+
49
+ private
50
+ def self.endpoint
51
+ "cancel/request"
52
+ end
53
+ end
54
+ end
@@ -1,9 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module GetnetApi
3
3
  module Version
4
- MAJOR = 0
5
- MINOR = 1
6
- PATCH = 2
4
+ MAJOR = 1
5
+ MINOR = 0
6
+ PATCH = 0
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
data/lib/getnet_api.rb CHANGED
@@ -14,6 +14,7 @@ require "getnet_api/order"
14
14
  require "getnet_api/boleto"
15
15
  require "getnet_api/credit"
16
16
  require "getnet_api/payment"
17
+ require "getnet_api/payment_cancel"
17
18
 
18
19
 
19
20
  # -*- encoding : utf-8 -*-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getnet_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - QW3 Software & Marketing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -52,6 +52,7 @@ files:
52
52
  - lib/getnet_api/customer.rb
53
53
  - lib/getnet_api/order.rb
54
54
  - lib/getnet_api/payment.rb
55
+ - lib/getnet_api/payment_cancel.rb
55
56
  - lib/getnet_api/version.rb
56
57
  homepage: https://github.com/qw3/getnet_api
57
58
  licenses: