Class: PagSeguro::Authorization

Inherits:
Object
  • Object
show all
Includes:
Extensions::Credentiable, Extensions::MassAssignment
Defined in:
lib/pagseguro/authorization.rb,
lib/pagseguro/authorization/response.rb,
lib/pagseguro/authorization/collection.rb,
lib/pagseguro/authorization/request_serializer.rb,
lib/pagseguro/authorization/response_serializer.rb

Defined Under Namespace

Classes: Collection, RequestSerializer, Response, ResponseSerializer

Instance Attribute Summary collapse

Attributes included from Extensions::Credentiable

#credentials

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extensions::MassAssignment

#initialize

Instance Attribute Details

#codeObject

The authorization code



7
8
9
# File 'lib/pagseguro/authorization.rb', line 7

def code
  @code
end

#created_atObject

The authorization creation date



10
11
12
# File 'lib/pagseguro/authorization.rb', line 10

def created_at
  @created_at
end

#permissionsObject

The authorization permissions



16
17
18
# File 'lib/pagseguro/authorization.rb', line 16

def permissions
  @permissions
end

#referenceObject

The reference related to the authorization



13
14
15
# File 'lib/pagseguro/authorization.rb', line 13

def reference
  @reference
end

Class Method Details

.find_by(options) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/pagseguro/authorization.rb', line 36

def self.find_by(options)
  request = Request.get("authorizations", api_version, RequestSerializer.new(options).to_params)
  collection = Collection.new
  Response.new(request, collection).serialize_collection

  collection
end

.find_by_code(code, options = {}) ⇒ Object

Find an authorization by it’s code



28
29
30
31
32
33
34
# File 'lib/pagseguro/authorization.rb', line 28

def self.find_by_code(code, options = {})
  request = Request.get("authorizations/#{code}", api_version, options)
  authorization = PagSeguro::Authorization.new
  Response.new(request, authorization).serialize

  authorization
end

.find_by_notification_code(code, options = {}) ⇒ Object

Find an authorization by it’s notification code



19
20
21
22
23
24
25
# File 'lib/pagseguro/authorization.rb', line 19

def self.find_by_notification_code(code, options = {})
  request = Request.get("authorizations/notifications/#{code}", api_version, options)
  authorization = PagSeguro::Authorization.new
  Response.new(request, authorization).serialize

  authorization
end

Instance Method Details

#errorsObject



48
49
50
# File 'lib/pagseguro/authorization.rb', line 48

def errors
  @errors ||= Errors.new
end

#update_attributes(attrs) ⇒ Object



44
45
46
# File 'lib/pagseguro/authorization.rb', line 44

def update_attributes(attrs)
  attrs.map { |name, value| send("#{name}=", value) }
end