pagseguro_next 1.0.2 → 1.0.3

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: 412744374e66de13dd65e06ecaabb4e6b57787d53765f7d5d4c8a23225915d0e
4
- data.tar.gz: e099b9a32083df965fc77c80a10bcb163a0b020f719a6725bd1e5a2acbbc44ba
3
+ metadata.gz: 0f43819004d41517e301f66e97041c734ac768ac44bf153968269af593b7b733
4
+ data.tar.gz: 618f51e08efa566e67631e7593f49fec311827f513400b902bbd952592e538db
5
5
  SHA512:
6
- metadata.gz: afe9ed2caf22a1e5e38cbea8c0c09e0c1ed857a1c1791b0d1b54c55a67159db23b5fa24f6c823e90194d2c9eb8c17e79c7d44ece0a21f5f178c94e0dbc2b774c
7
- data.tar.gz: d8cf7e96bd8ddf49fc1fc0fbdde22550bfc70230934f999d3fcd5badcef146b0da5f46a24a387c82388b26d1022a2aad1ff4fa1e931534b0a896c96651f730e2
6
+ metadata.gz: dcbaf6f57dcc9bc916d05851c427faf47972a342c1e398fb293887a32fc93163757414a04652bfed6d76be20fdbce67101a14a24feb38577bb8550cbafc77282
7
+ data.tar.gz: d052151d6b1e2f2f47a43540bc1489a5132559d081b91660db89773b62d52ccc69fb13e394ae77692cd90b0384f089d0e428bab868e942a9d4d77407e842253e
data/lib/pagseguro.rb CHANGED
@@ -20,13 +20,13 @@ module PagSeguro
20
20
  autoload :Mash, "pagseguro/mash"
21
21
 
22
22
  ACCEPTS = {
23
- json: "application/vnd.pagseguro.com.br.v3+xml;charset=ISO-8859-1",
24
- xml: "application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1"
23
+ json: "application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1",
24
+ xml: "application/vnd.pagseguro.com.br.v3+xml;charset=ISO-8859-1"
25
25
  }
26
26
 
27
27
  FORMATS = {
28
- json: "application/json",
29
- xml: "application/xml"
28
+ json: "application/json;charset=ISO-8859-1",
29
+ xml: "application/xml;charset=ISO-8859-1"
30
30
  }
31
31
 
32
32
  mattr_accessor :token
@@ -16,13 +16,13 @@ module PagSeguro
16
16
  }
17
17
 
18
18
  def create(params)
19
- xml = build_request(params).to_xml
20
- response = post_xml("/v2/authorizations/request", xml)
19
+ body = build_request(params).to_xml
20
+ response = post("/v2/authorizations/request", body, xml: :simple)
21
21
  response.authorization_request
22
22
  end
23
23
 
24
24
  def find_by_notification_code(code)
25
- response = get_xml("/v2/authorizations/notifications/#{code}")
25
+ response = get("/v2/authorizations/notifications/#{code}", nil, xml: :simple)
26
26
  response.authorization
27
27
  end
28
28
 
@@ -5,8 +5,8 @@ module PagSeguro
5
5
  include Restful
6
6
 
7
7
  def create(params)
8
- params = build_request(params).to_xml(encoding: "UTF-8")
9
- response = post_xml("/v2/checkout", params)
8
+ body = build_request(params).to_xml(encoding: "UTF-8")
9
+ response = post("/v2/checkout", body, xml: :simple)
10
10
  response.checkout
11
11
  end
12
12
 
@@ -5,8 +5,7 @@ module PagSeguro
5
5
  include Restful
6
6
 
7
7
  def fetch(code, params = {})
8
- params.reverse_merge! status: 5, page: 0
9
- response = get("/pre-approvals/#{code}/payment-orders", params)
8
+ response = get("/pre-approvals/#{code}/payment-orders", params, {})
10
9
  response.paymentOrders.values || {}
11
10
  end
12
11
  end
@@ -5,8 +5,8 @@ module PagSeguro
5
5
  include Restful
6
6
 
7
7
  def create(params)
8
- xml = build_request(params).to_xml
9
- post_xml("/pre-approvals/request", xml)
8
+ body = build_request(params).to_xml
9
+ post("/pre-approvals/request", body, xml: :versioned)
10
10
  end
11
11
 
12
12
  def update(code, params)
@@ -13,11 +13,13 @@ module PagSeguro
13
13
  end
14
14
 
15
15
  protected
16
- def get(path, options = nil, headers = nil)
16
+ def get(path, options = {}, xml: nil)
17
+ headers = headerize(xml) if xml
17
18
  connection.get(path, options, headers).body
18
19
  end
19
20
 
20
- def post(path, options = nil, headers = nil)
21
+ def post(path, options = {}, xml: nil)
22
+ headers = headerize(xml) if xml
21
23
  connection.post(path, options, headers).body
22
24
  end
23
25
 
@@ -33,16 +35,12 @@ module PagSeguro
33
35
  connection.delete(path, options).body
34
36
  end
35
37
 
36
- def xml_headers
37
- { accept: ACCEPTS[:xml], content_type: FORMATS[:xml] }
38
- end
39
-
40
- def get_xml(path, options = nil)
41
- get(path, options, xml_headers)
42
- end
43
-
44
- def post_xml(path, options = nil)
45
- post(path, options, xml_headers)
38
+ def headerize(xml)
39
+ if xml == :simple
40
+ { accept: FORMATS[:xml], content_type: FORMATS[:xml] }
41
+ elsif xml == :versioned
42
+ { accept: ACCEPTS[:xml], content_type: FORMATS[:xml] }
43
+ end
46
44
  end
47
45
 
48
46
  def parameterize(hash)
@@ -5,7 +5,7 @@ module PagSeguro
5
5
  include Restful
6
6
 
7
7
  def create
8
- response = post_xml("/v2/sessions")
8
+ response = post("/v2/sessions", nil, xml: :simple)
9
9
  response.session
10
10
  end
11
11
  end
@@ -18,11 +18,11 @@ module PagSeguro
18
18
  }
19
19
 
20
20
  def find(code)
21
- transform get_xml("/v3/transactions/#{code}")
21
+ transform get("/v3/transactions/#{code}", nil, xml: :simple)
22
22
  end
23
23
 
24
24
  def find_by_notification_code(code)
25
- transform get_xml("/v2/transactions/notifications/#{code}")
25
+ transform get("/v2/transactions/notifications/#{code}", nil, xml: :simple)
26
26
  end
27
27
 
28
28
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PagSeguro
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagseguro_next
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rainer Borene