class PagSeguro::AuthorizationRequest

Constants

PERMISSIONS

Attributes

account[R]

The account that can be passed to register suggestion

code[RW]

The code used to confirm the authorization

date[RW]

The date of authorization creation

errors[W]

Errors object.

notification_url[RW]

The url which PagSeguro can send notifications

permissions[RW]

The permissions given to the application Defaults to all permissions

redirect_url[RW]

The url which the application is going to be redirected after the proccess

reference[RW]

The seller reference (optional)

Public Instance Methods

account=(account) click to toggle source
# File lib/pagseguro/authorization_request.rb, line 42
def account=(account)
  @account = ensure_type(Account, account)
end
create() click to toggle source

Post and create an Authorization. Return Boolean.

# File lib/pagseguro/authorization_request.rb, line 48
def create
  request = Request.post_xml('authorizations/request', api_version, credentials, xml)
  response = Response.new(request)
  update_attributes(response.serialize)

  response.success?
end
errors() click to toggle source
# File lib/pagseguro/authorization_request.rb, line 61
def errors
  @errors ||= Errors.new
end
url() click to toggle source

URL to confirm authorization after create one.

# File lib/pagseguro/authorization_request.rb, line 57
def url
  PagSeguro.site_url("#{api_version}/authorization/request.jhtml?code=#{code}") if code
end

Private Instance Methods

api_version() click to toggle source
# File lib/pagseguro/authorization_request.rb, line 80
def api_version
  'v2'
end
before_initialize() click to toggle source
# File lib/pagseguro/authorization_request.rb, line 68
def before_initialize
  self.permissions = PERMISSIONS.keys
end
update_attributes(attrs) click to toggle source
# File lib/pagseguro/authorization_request.rb, line 76
def update_attributes(attrs)
  attrs.each { |method, value| send("#{method}=", value) }
end
xml() click to toggle source
# File lib/pagseguro/authorization_request.rb, line 72
def xml
  RequestSerializer.new(self).build_xml
end