module PagSeguro::Restful

Attributes

client[R]

Public Class Methods

new(client) click to toggle source
# File lib/pagseguro/restful.rb, line 11
def initialize(client)
  @client = client
end

Protected Instance Methods

builder(&block) click to toggle source
# File lib/pagseguro/restful.rb, line 50
def builder(&block)
  Nokogiri::XML::Builder.new { |xml| xml.instance_eval(&block) }
end
delete(path, options = {}) click to toggle source
# File lib/pagseguro/restful.rb, line 34
def delete(path, options = {})
  connection.delete(path, options).body
end
get(path, options = {}, xml: nil) click to toggle source
# File lib/pagseguro/restful.rb, line 16
def get(path, options = {}, xml: nil)
  headers = headerize(xml) if xml
  connection.get(path, options, headers).body
end
headerize(xml) click to toggle source
# File lib/pagseguro/restful.rb, line 38
def headerize(xml)
  if xml == :simple
    { accept: FORMATS[:xml], content_type: FORMATS[:xml] }
  elsif xml == :versioned
    { accept: ACCEPTS[:xml], content_type: FORMATS[:xml] }
  end
end
parameterize(hash) click to toggle source
# File lib/pagseguro/restful.rb, line 46
def parameterize(hash)
  hash.as_json.deep_transform_keys! { |key| key.to_s.camelize(:lower) }
end
patch(path, options = {}) click to toggle source
# File lib/pagseguro/restful.rb, line 30
def patch(path, options = {})
  connection.patch(path, options).body
end
post(path, options = {}, xml: nil) click to toggle source
# File lib/pagseguro/restful.rb, line 21
def post(path, options = {}, xml: nil)
  headers = headerize(xml) if xml
  connection.post(path, options, headers).body
end
put(path, options = {}) click to toggle source
# File lib/pagseguro/restful.rb, line 26
def put(path, options = {})
  connection.put(path, options).body
end