Class: PagSeguro::SubscriptionChangeStatus

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

Defined Under Namespace

Classes: RequestSerializer, Response

Constant Summary collapse

STATUSES =

Now, just available ACTIVE and SUSPENDED

{
  active: 'ACTIVE',
  suspended: 'SUSPENDED'
}

Instance Attribute Summary collapse

Attributes included from Extensions::Credentiable

#credentials

Instance Method Summary collapse

Constructor Details

#initialize(code, status) ⇒ SubscriptionChangeStatus

Returns a new instance of SubscriptionChangeStatus.



18
19
20
21
# File 'lib/pagseguro/subscription_change_status.rb', line 18

def initialize(code, status)
  @code = code
  @status = status
end

Instance Attribute Details

#codeObject (readonly)

Subscription’s code that will be changed



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

def code
  @code
end

#statusObject (readonly)

The status that will be set



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

def status
  @status
end

Instance Method Details

#errorsObject

Set errors



24
25
26
# File 'lib/pagseguro/subscription_change_status.rb', line 24

def errors
  @errors ||= Errors.new
end

#saveObject



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

def save
  request = Request.put_xml("pre-approvals/#{code}/status", credentials, params)

  Response.new(request, self).serialize

  self
end

#status_textObject



36
37
38
# File 'lib/pagseguro/subscription_change_status.rb', line 36

def status_text
  STATUSES[status]
end