Class: PagSeguro::Client
- Inherits:
-
Object
- Object
- PagSeguro::Client
- Defined in:
- lib/pagseguro/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #authorizations ⇒ Object
- #checkout ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #payment_orders ⇒ Object
- #plans ⇒ Object
- #sessions ⇒ Object
- #subscriptions ⇒ Object
- #transactions ⇒ Object
- #url_for(source, path, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pagseguro/client.rb', line 10 def initialize( = {}) @options = @logger = .delete(:logger) @connection = Faraday.new api_url do |conn| conn.request :json conn.response :logger, logger, bodies: true if logger conn.response :mashify, mash_class: PagSeguro::Mash conn.response :xml, content_type: /\bxml$/ conn.response :json, content_type: /\bjson$/ conn.response :raise_error conn.adapter :net_http conn.params = auth_params conn.headers[:accept] = ACCEPTS[:json] end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
8 9 10 |
# File 'lib/pagseguro/client.rb', line 8 def connection @connection end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/pagseguro/client.rb', line 8 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/pagseguro/client.rb', line 8 def @options end |
Instance Method Details
#authorizations ⇒ Object
42 43 44 |
# File 'lib/pagseguro/client.rb', line 42 def @authorizations ||= Authorizations.new(self) end |
#checkout ⇒ Object
46 47 48 |
# File 'lib/pagseguro/client.rb', line 46 def checkout @checkout ||= Checkout.new(self) end |
#payment_orders ⇒ Object
30 31 32 |
# File 'lib/pagseguro/client.rb', line 30 def payment_orders @payment_orders ||= PaymentOrders.new(self) end |
#plans ⇒ Object
38 39 40 |
# File 'lib/pagseguro/client.rb', line 38 def plans @plans ||= Plans.new(self) end |
#sessions ⇒ Object
34 35 36 |
# File 'lib/pagseguro/client.rb', line 34 def sessions @sessions ||= Sessions.new(self) end |
#subscriptions ⇒ Object
26 27 28 |
# File 'lib/pagseguro/client.rb', line 26 def subscriptions @subscriptions ||= Subscriptions.new(self) end |
#transactions ⇒ Object
50 51 52 |
# File 'lib/pagseguro/client.rb', line 50 def transactions @transactions ||= Transactions.new(self) end |
#url_for(source, path, params = {}) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/pagseguro/client.rb', line 54 def url_for(source, path, params = {}) url = URI(send("#{source}_url")) url.path = path url.query = params.to_query url.to_s end |