pagseguro_next 0.4.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 386a91a6255a8b025d7f02faa5a322c85cb33644ad820a0cb3936746b6a42856
4
- data.tar.gz: b3386d893d71e2d7d3d8c3038ef0a2d78a609c2ef95758524eba20f29bb80bb6
3
+ metadata.gz: eb0d9520494b52e758dc24754adce5056e7bd3838bebf18aade8e9e12be07c21
4
+ data.tar.gz: b01d9f1954b4a03b0881e409b0f4b342f44498008c513e204df2fbb34cf7db90
5
5
  SHA512:
6
- metadata.gz: 4ae3b989310eae3ba2aac2053023cdeeed67b91fa2ebc97f94ac74b6943b015f8efd783755bd13fe90870e0eb5763410269b3e746706513fd84af2aef2261547
7
- data.tar.gz: 1fac01e0a11ddddf1fddee73325c33deb6250741f3c3eaca1c65382801a08e38bfd665257328d0bb1cb02ec5dbd74c18a72a3f563b2d5af2f12d2e841ce84398
6
+ metadata.gz: 2dbe1603b742149203287734b6838455a1dde4be580c19a6668350d2acb6411918f14c1b376755414d62b3cae7ffac0761135ab0e1dec23045c7715e9859a64a
7
+ data.tar.gz: fddf07dd339714cdea4f280ae46c1a936edf7c26b704da2ed56a99965aacd4a775b6f7f6e59a9d6819dc5202451daf4882c18d994813038ef86c0023948b7690
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
 
4
- Rake::TestTask.new(:spec) do |t|
5
- t.libs << "spec"
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
6
8
  t.libs << "lib"
7
- t.test_files = FileList["spec/**/*_spec.rb"]
9
+ t.test_files = FileList["test/**/*_test.rb"]
8
10
  end
9
11
 
10
- task default: :spec
12
+ task default: :test
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- class Authorizations < Base
4
+ class Authorizations
5
+ include Restful
6
+
3
7
  PERMISSIONS = {
4
8
  checkouts: "CREATE_CHECKOUTS",
5
9
  notifications: "RECEIVE_TRANSACTION_NOTIFICATIONS",
@@ -13,41 +17,31 @@ module PagSeguro
13
17
 
14
18
  def create(params)
15
19
  xml = build_request(params).to_xml
16
-
17
- response = api.post "/v2/authorizations/request", xml do |conn|
18
- conn.headers[:content_type] = FORMATS[:xml]
19
- conn.headers[:accept] = FORMATS[:xml]
20
- end
21
-
22
- parse response.body["authorizationRequest"]
20
+ response = post_xml("/v2/authorizations/request", xml)
21
+ response.authorization_request
23
22
  end
24
23
 
25
24
  def find_by_notification_code(code)
26
- response = api.get "/v2/authorizations/notifications/#{code}" do |conn|
27
- conn.headers[:content_type] = FORMATS[:xml]
28
- conn.headers[:accept] = FORMATS[:xml]
29
- end
30
-
31
- parse response.body["authorization"]
25
+ response = get_xml("/v2/authorizations/notifications/#{code}")
26
+ response.authorization
32
27
  end
33
28
 
34
29
  def url(code)
35
- api.build_url :site, "/v2/authorization/request.jhtml", code: code
30
+ url_for :site, "/v2/authorization/request.jhtml", code: code
36
31
  end
37
32
 
38
33
  private
39
-
40
- def build_request(params)
41
- builder do
42
- authorizationRequest do
43
- redirectURL params[:redirect_url]
44
- permissions do
45
- params[:permissions].each do |aliased|
46
- code PERMISSIONS[aliased]
34
+ def build_request(params)
35
+ builder do
36
+ authorizationRequest do
37
+ redirectURL params[:redirect_url]
38
+ permissions do
39
+ params[:permissions].each do |aliased|
40
+ code PERMISSIONS[aliased]
41
+ end
47
42
  end
48
43
  end
49
44
  end
50
45
  end
51
- end
52
46
  end
53
47
  end
@@ -1,42 +1,40 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- class Checkout < Base
4
+ class Checkout
5
+ include Restful
6
+
3
7
  def create(params)
4
8
  params = build_request(params).to_xml(encoding: "UTF-8")
5
-
6
- response = api.post "/v2/checkout", params do |conn|
7
- conn.headers[:content_type] = FORMATS[:xml]
8
- conn.headers[:accept] = FORMATS[:xml]
9
- end
10
-
11
- parse response.body["checkout"]
9
+ response = post_xml("/v2/checkout", params)
10
+ response.checkout
12
11
  end
13
12
 
14
13
  def url(code)
15
- api.build_url :site, "/v2/checkout/payment.html", code: code
14
+ url_for :site, "/v2/checkout/payment.html", code: code
16
15
  end
17
16
 
18
17
  private
19
-
20
- def build_request(params)
21
- builder do
22
- checkout do
23
- currency "BRL"
24
- sender do
25
- ip params[:remote_ip]
26
- end if params.key?(:remote_ip)
27
- items do
28
- item do
29
- id params[:id]
30
- description { cdata(params[:description]) }
31
- amount format("%.2f", params[:amount].to_f)
32
- quantity 1
18
+ def build_request(params)
19
+ builder do
20
+ checkout do
21
+ currency "BRL"
22
+ sender do
23
+ ip params[:remote_ip]
24
+ end if params.key?(:remote_ip)
25
+ items do
26
+ item do
27
+ id params[:id]
28
+ description { cdata(params[:description]) }
29
+ amount format("%.2f", params[:amount].to_f)
30
+ quantity 1
31
+ end
32
+ end
33
+ shipping do
34
+ addressRequired false
33
35
  end
34
- end
35
- shipping do
36
- addressRequired false
37
36
  end
38
37
  end
39
38
  end
40
- end
41
39
  end
42
40
  end
@@ -1,20 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "faraday"
2
4
  require "faraday_middleware"
3
5
 
4
6
  module PagSeguro
5
- class API
6
- delegate :get, :post, :put, :patch, to: :@connection
7
-
8
- attr_reader :options, :logger
7
+ class Client
8
+ attr_reader :options, :logger, :connection
9
9
 
10
10
  def initialize(options = {})
11
11
  @options = options
12
12
  @logger = options.delete(:logger)
13
- @connection ||= Faraday.new api_url do |conn|
13
+ @connection = Faraday.new api_url do |conn|
14
14
  conn.request :json
15
+ conn.response :logger, logger, bodies: true if logger
16
+ conn.response :mashify, mash_class: PagSeguro::Mash
15
17
  conn.response :xml, content_type: /\bxml$/
16
18
  conn.response :json, content_type: /\bjson$/
17
- conn.response :logger, logger, bodies: true if logger
19
+ conn.response :raise_error
18
20
  conn.adapter :net_http
19
21
  conn.params = auth_params
20
22
  conn.headers[:accept] = FORMATS[:json]
@@ -49,40 +51,39 @@ module PagSeguro
49
51
  @transactions ||= Transactions.new(self)
50
52
  end
51
53
 
52
- def build_url(source, path, params = {})
54
+ def url_for(source, path, params = {})
53
55
  url = URI(send("#{source}_url"))
54
56
  url.path = path
55
57
  url.query = params.to_query
56
58
  url.to_s
57
59
  end
58
60
 
59
- private
61
+ protected
62
+ def environment
63
+ options[:environment] || PagSeguro.environment
64
+ end
60
65
 
61
- def site_url
62
- PagSeguro.uris[environment.to_sym][:site]
63
- end
66
+ def site_url
67
+ PagSeguro.uris[environment.to_sym][:site]
68
+ end
64
69
 
65
- def api_url
66
- PagSeguro.uris[environment.to_sym][:api]
67
- end
70
+ def api_url
71
+ PagSeguro.uris[environment.to_sym][:api]
72
+ end
68
73
 
69
- def environment
70
- options[:environment] || PagSeguro.environment
71
- end
74
+ def auth_params
75
+ auth = {}
72
76
 
73
- def auth_params
74
- auth = {}
77
+ if options.key?(:app) || options.key?(:app_id)
78
+ auth[:appId] = options.fetch :app_id, PagSeguro.app_id
79
+ auth[:appKey] = options.fetch :app_key, PagSeguro.app_key
80
+ auth[:authorizationCode] = options[:authorization_code]
81
+ else
82
+ auth[:token] = options.fetch :token, PagSeguro.token
83
+ auth[:email] = options.fetch :email, PagSeguro.email
84
+ end
75
85
 
76
- if options.key?(:app) || options.key?(:app_id)
77
- auth[:appId] = options.fetch :app_id, PagSeguro.app_id
78
- auth[:appKey] = options.fetch :app_key, PagSeguro.app_key
79
- auth[:authorizationCode] = options[:authorization_code]
80
- else
81
- auth[:token] = options.fetch :token, PagSeguro.token
82
- auth[:email] = options.fetch :email, PagSeguro.email
86
+ auth.compact
83
87
  end
84
-
85
- auth.compact
86
- end
87
88
  end
88
89
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module PagSeguro
6
+ class Mash < Hashie::Mash
7
+ protected
8
+ def convert_key(key)
9
+ key.to_s.underscore
10
+ end
11
+
12
+ def convert_value(val, duping = false)
13
+ obj = super
14
+ obj = self.class.new(obj) if Hashie::Mash == obj
15
+ obj
16
+ end
17
+
18
+ def initializing_reader(key)
19
+ ck = convert_key(key)
20
+ regular_writer(ck, self.class.new) unless key?(ck)
21
+ regular_reader(ck)
22
+ end
23
+ end
24
+ end
@@ -1,20 +1,13 @@
1
- module PagSeguro
2
- class PaymentOrders < Base
3
- class Item < Hashie::Dash
4
- include Hashie::Extensions::Dash::PropertyTranslation
5
- include Hashie::Extensions::IgnoreUndeclared
6
- include Hashie::Extensions::IndifferentAccess
1
+ # frozen_string_literal: true
7
2
 
8
- property :amount, transform_with: ->(value) { format "R$%.2f", value }
9
- property :scheduling_date, from: :schedulingDate, transform_with: ->(value) { value.to_date }
10
- property :last_event_date, from: :lastEventDate, transform_with: ->(value) { value.to_date }
11
- end
3
+ module PagSeguro
4
+ class PaymentOrders
5
+ include Restful
12
6
 
13
7
  def fetch(code, params = {})
14
8
  params.reverse_merge! status: 5, page: 0
15
- response = api.get("/pre-approvals/#{code}/payment-orders", params)
16
- orders = response.body["paymentOrders"] || {}
17
- orders.values.map { |item| Item.new item }
9
+ response = get("/pre-approvals/#{code}/payment-orders", params)
10
+ response.paymentOrders.values || {}
18
11
  end
19
12
  end
20
13
  end
@@ -1,23 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- class Plans < Base
4
+ class Plans
5
+ include Restful
6
+
3
7
  def create(params)
4
8
  params[:amount_per_payment] = to_money params[:amount_per_payment]
5
9
  params = parameterize params
6
10
 
7
- parse_body api.post("/pre-approvals/request", preApproval: params)
11
+ post("/pre-approvals/request", preApproval: params)
8
12
  end
9
13
 
10
14
  def update(code, params)
11
15
  params[:amount_per_payment] = to_money params[:amount_per_payment]
12
16
  params = parameterize params
13
17
 
14
- api.put "/pre-approvals/request/#{code}/payment", params
18
+ put("/pre-approvals/request/#{code}/payment", params)
15
19
  end
16
20
 
17
21
  private
18
-
19
- def to_money(value)
20
- format "%.2f", value.to_f
21
- end
22
+ def to_money(value)
23
+ format "%.2f", value.to_f
24
+ end
22
25
  end
23
26
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "nokogiri"
4
+
5
+ module PagSeguro
6
+ module Restful
7
+ attr_reader :client
8
+
9
+ delegate :url_for, :connection, to: :client
10
+
11
+ def initialize(client)
12
+ @client = client
13
+ end
14
+
15
+ protected
16
+ def get(path, options = nil, &block)
17
+ connection.get(path, options, &block).body
18
+ end
19
+
20
+ def post(path, options = nil, &block)
21
+ connection.post(path, options, &block).body
22
+ end
23
+
24
+ def put(path, options = {})
25
+ connection.put(path, options).body
26
+ end
27
+
28
+ def patch(path, options = {})
29
+ connection.patch(path, options).body
30
+ end
31
+
32
+ def delete(path, options = {})
33
+ connection.delete(path, options).body
34
+ end
35
+
36
+ def get_xml(path, options = nil)
37
+ get(path, options) do |conn|
38
+ conn.headers[:content_type] = FORMATS[:xml]
39
+ conn.headers[:accept] = FORMATS[:xml]
40
+ end
41
+ end
42
+
43
+ def post_xml(path, options = nil)
44
+ post(path) do |conn|
45
+ conn.headers[:content_type] = FORMATS[:xml]
46
+ conn.headers[:accept] = FORMATS[:xml]
47
+ end
48
+ end
49
+
50
+ def parameterize(hash)
51
+ hash.as_json.deep_transform_keys! do |key|
52
+ key.to_s.camelize(:lower)
53
+ end
54
+ end
55
+
56
+ def builder(&block)
57
+ Nokogiri::XML::Builder.new do |xml|
58
+ xml.instance_eval(&block)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- class Sessions < Base
3
- def create
4
- response = api.post "/v2/sessions" do |conn|
5
- conn.headers[:accept] = FORMATS[:xml]
6
- end
4
+ class Sessions
5
+ include Restful
7
6
 
8
- parse response.body["session"]
7
+ def create
8
+ response = post_xml("/v2/sessions")
9
+ response.session
9
10
  end
10
11
  end
11
12
  end
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- class Subscriptions < Base
4
+ class Subscriptions
5
+ include Restful
6
+
3
7
  def find_by_notification_code(code)
4
- parse_body api.get("/pre-approvals/notifications/#{code}")
8
+ get("/pre-approvals/notifications/#{code}")
5
9
  end
6
10
 
7
11
  def create(params)
8
12
  params = parameterize params
9
-
10
- parse_body api.post("/pre-approvals", params)
13
+ post("/pre-approvals", params)
11
14
  end
12
15
 
13
16
  def update(code, params)
14
17
  params = parameterize params
15
-
16
- api.put("/pre-approvals/#{code}/payment-method", params)
18
+ put("/pre-approvals/#{code}/payment-method", params)
17
19
  end
18
20
 
19
21
  def url(code)
20
- api.build_url :site, "/v2/pre-approvals/request.html", code: code
22
+ url_for :site, "/v2/pre-approvals/request.html", code: code
21
23
  end
22
24
  end
23
25
  end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- class Transactions < Base
4
+ class Transactions
5
+ include Restful
6
+
3
7
  STATUSES = {
4
8
  "0" => :initiated,
5
9
  "1" => :waiting_payment,
@@ -14,25 +18,15 @@ module PagSeguro
14
18
  }
15
19
 
16
20
  def find(code)
17
- response = api.get "/v3/transactions/#{code}" do |conn|
18
- conn.headers[:accept] = FORMATS[:xml]
19
- end
20
-
21
- parse_body response
21
+ transform get_xml("/v3/transactions/#{code}")
22
22
  end
23
23
 
24
24
  def find_by_notification_code(code)
25
- response = api.get "/v2/transactions/notifications/#{code}" do |conn|
26
- conn.headers[:accept] = FORMATS[:xml]
27
- end
28
-
29
- parse_body response
25
+ transform get_xml("/v2/transactions/notifications/#{code}")
30
26
  end
31
27
 
32
28
  private
33
-
34
- def parse_body(response)
35
- parse(response.body).yield_self do |body|
29
+ def transform(body)
36
30
  if body.transaction?
37
31
  body.transaction.status = STATUSES[body.transaction.status]
38
32
  body.transaction
@@ -42,6 +36,5 @@ module PagSeguro
42
36
  body
43
37
  end
44
38
  end
45
- end
46
39
  end
47
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagSeguro
2
- VERSION = "0.4.0"
4
+ VERSION = "1.0.1"
3
5
  end
data/lib/pagseguro.rb CHANGED
@@ -1,4 +1,5 @@
1
- require "hashie"
1
+ # frozen_string_literal: true
2
+
2
3
  require "active_support/core_ext/string/inflections"
3
4
  require "active_support/core_ext/module/delegation"
4
5
  require "active_support/core_ext/hash/reverse_merge"
@@ -7,8 +8,8 @@ require "active_support/core_ext/object/json"
7
8
  require "active_support/core_ext/module/attribute_accessors"
8
9
 
9
10
  module PagSeguro
10
- autoload :API, "pagseguro/api"
11
- autoload :Base, "pagseguro/base"
11
+ autoload :Client, "pagseguro/client"
12
+ autoload :Restful, "pagseguro/restful"
12
13
  autoload :Subscriptions, "pagseguro/subscriptions"
13
14
  autoload :PaymentOrders, "pagseguro/payment_orders"
14
15
  autoload :Sessions, "pagseguro/sessions"
@@ -16,7 +17,7 @@ module PagSeguro
16
17
  autoload :Authorizations, "pagseguro/authorizations"
17
18
  autoload :Checkout, "pagseguro/checkout"
18
19
  autoload :Transactions, "pagseguro/transactions"
19
- autoload :Response, "pagseguro/response"
20
+ autoload :Mash, "pagseguro/mash"
20
21
 
21
22
  FORMATS = {
22
23
  json: "application/vnd.pagseguro.com.br.v3+json;charset=ISO-8859-1",
@@ -40,8 +41,8 @@ module PagSeguro
40
41
  site: "https://pagseguro.uol.com.br"
41
42
  },
42
43
  sandbox: {
43
- site: "https://sandbox.pagseguro.uol.com.br",
44
- api: "https://ws.sandbox.pagseguro.uol.com.br"
44
+ api: "https://ws.sandbox.pagseguro.uol.com.br",
45
+ site: "https://sandbox.pagseguro.uol.com.br"
45
46
  }
46
47
  }
47
48
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "pagseguro"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path("../lib", __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require "pagseguro/version"
@@ -16,14 +18,15 @@ Gem::Specification.new do |spec|
16
18
  spec.files += Dir.glob("lib/**/*.rb")
17
19
  spec.require_paths = ["lib"]
18
20
 
19
- spec.add_dependency "faraday", [">= 0.7.4", "< 1.0"]
21
+ spec.add_dependency "faraday", "~> 0.17"
20
22
  spec.add_dependency "faraday_middleware", "~> 0.13"
21
- spec.add_dependency "hashie", [">= 3.4.6", "< 3.7.0"]
23
+ spec.add_dependency "hashie", ">= 3.4.6"
22
24
  spec.add_dependency "nokogiri", ">= 1.6"
23
25
  spec.add_dependency "activesupport", ">= 4"
26
+ spec.add_dependency "multi_xml", "~> 0.6"
24
27
 
25
28
  spec.add_development_dependency "bundler", "~> 1.17"
26
- spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rake", ">= 12.3.3"
27
30
  spec.add_development_dependency "minitest", "~> 5.0"
28
31
  spec.add_development_dependency "vcr", "~> 4.0"
29
32
  spec.add_development_dependency "webmock", "~> 3.5"
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagseguro_next
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rainer Borene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-09 00:00:00.000000000 Z
11
+ date: 2020-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.7.4
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '1.0'
19
+ version: '0.17'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.7.4
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '1.0'
26
+ version: '0.17'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: faraday_middleware
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -51,9 +45,6 @@ dependencies:
51
45
  - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: 3.4.6
54
- - - "<"
55
- - !ruby/object:Gem::Version
56
- version: 3.7.0
57
48
  type: :runtime
58
49
  prerelease: false
59
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -61,9 +52,6 @@ dependencies:
61
52
  - - ">="
62
53
  - !ruby/object:Gem::Version
63
54
  version: 3.4.6
64
- - - "<"
65
- - !ruby/object:Gem::Version
66
- version: 3.7.0
67
55
  - !ruby/object:Gem::Dependency
68
56
  name: nokogiri
69
57
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +80,20 @@ dependencies:
92
80
  - - ">="
93
81
  - !ruby/object:Gem::Version
94
82
  version: '4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: multi_xml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
95
97
  - !ruby/object:Gem::Dependency
96
98
  name: bundler
97
99
  requirement: !ruby/object:Gem::Requirement
@@ -110,16 +112,16 @@ dependencies:
110
112
  name: rake
111
113
  requirement: !ruby/object:Gem::Requirement
112
114
  requirements:
113
- - - "~>"
115
+ - - ">="
114
116
  - !ruby/object:Gem::Version
115
- version: '10.0'
117
+ version: 12.3.3
116
118
  type: :development
117
119
  prerelease: false
118
120
  version_requirements: !ruby/object:Gem::Requirement
119
121
  requirements:
120
- - - "~>"
122
+ - - ">="
121
123
  - !ruby/object:Gem::Version
122
- version: '10.0'
124
+ version: 12.3.3
123
125
  - !ruby/object:Gem::Dependency
124
126
  name: minitest
125
127
  requirement: !ruby/object:Gem::Requirement
@@ -172,13 +174,13 @@ files:
172
174
  - README.md
173
175
  - Rakefile
174
176
  - lib/pagseguro.rb
175
- - lib/pagseguro/api.rb
176
177
  - lib/pagseguro/authorizations.rb
177
- - lib/pagseguro/base.rb
178
178
  - lib/pagseguro/checkout.rb
179
+ - lib/pagseguro/client.rb
180
+ - lib/pagseguro/mash.rb
179
181
  - lib/pagseguro/payment_orders.rb
180
182
  - lib/pagseguro/plans.rb
181
- - lib/pagseguro/response.rb
183
+ - lib/pagseguro/restful.rb
182
184
  - lib/pagseguro/sessions.rb
183
185
  - lib/pagseguro/subscriptions.rb
184
186
  - lib/pagseguro/transactions.rb
@@ -1,31 +0,0 @@
1
- require "nokogiri"
2
-
3
- module PagSeguro
4
- class Base
5
- attr_reader :api
6
-
7
- def initialize(api)
8
- @api = api
9
- end
10
-
11
- def parse(hash)
12
- Response.new(hash)
13
- end
14
-
15
- def parse_body(response)
16
- parse response.body
17
- end
18
-
19
- def parameterize(hash)
20
- hash.as_json.deep_transform_keys! do |key|
21
- key.to_s.camelize(:lower)
22
- end
23
- end
24
-
25
- def builder(&block)
26
- Nokogiri::XML::Builder.new do |xml|
27
- xml.instance_eval(&block)
28
- end
29
- end
30
- end
31
- end
@@ -1,21 +0,0 @@
1
- module PagSeguro
2
- class Response < Hashie::Mash
3
- protected
4
-
5
- def convert_key(key)
6
- key.to_s.underscore
7
- end
8
-
9
- def convert_value(val, duping = false)
10
- obj = super
11
- obj = self.class.new(obj) if Hashie::Mash == obj
12
- obj
13
- end
14
-
15
- def initializing_reader(key)
16
- ck = convert_key(key)
17
- regular_writer(ck, self.class.new) unless key?(ck)
18
- regular_reader(ck)
19
- end
20
- end
21
- end