Class: PagSeguro::SubscriptionPlan

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

Defined Under Namespace

Classes: RequestSerializer, Response, ResponseSerializer

Constant Summary collapse

API_VERSION =
'v2'

Instance Attribute Summary collapse

Attributes included from Extensions::Credentiable

#credentials

Instance Method Summary collapse

Methods included from Extensions::EnsureType

#ensure_type

Methods included from Extensions::MassAssignment

#initialize

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#chargeObject

Returns the value of attribute charge.



11
12
13
# File 'lib/pagseguro/subscription_plan.rb', line 11

def charge
  @charge
end

#codeObject

Returns the value of attribute code.



22
23
24
# File 'lib/pagseguro/subscription_plan.rb', line 22

def code
  @code
end

#detailsObject

Returns the value of attribute details.



26
27
28
# File 'lib/pagseguro/subscription_plan.rb', line 26

def details
  @details
end

#final_dateObject

Returns the value of attribute final_date.



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

def final_date
  @final_date
end

#initial_dateObject

Returns the value of attribute initial_date.



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

def initial_date
  @initial_date
end

#max_amount_per_paymentObject

Returns the value of attribute max_amount_per_payment.



17
18
19
# File 'lib/pagseguro/subscription_plan.rb', line 17

def max_amount_per_payment
  @max_amount_per_payment
end

#max_amount_per_periodObject

Returns the value of attribute max_amount_per_period.



15
16
17
# File 'lib/pagseguro/subscription_plan.rb', line 15

def max_amount_per_period
  @max_amount_per_period
end

#max_payments_per_periodObject

Returns the value of attribute max_payments_per_period.



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

def max_payments_per_period
  @max_payments_per_period
end

#max_total_amountObject

Returns the value of attribute max_total_amount.



14
15
16
# File 'lib/pagseguro/subscription_plan.rb', line 14

def max_total_amount
  @max_total_amount
end

#max_usersObject

Returns the value of attribute max_users.



9
10
11
# File 'lib/pagseguro/subscription_plan.rb', line 9

def max_users
  @max_users
end

#membership_feeObject

Returns the value of attribute membership_fee.



20
21
22
# File 'lib/pagseguro/subscription_plan.rb', line 20

def membership_fee
  @membership_fee
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#periodObject

Returns the value of attribute period.



12
13
14
# File 'lib/pagseguro/subscription_plan.rb', line 12

def period
  @period
end

#redirect_urlObject

Returns the value of attribute redirect_url.



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

def redirect_url
  @redirect_url
end

#referenceObject

Returns the value of attribute reference.



23
24
25
# File 'lib/pagseguro/subscription_plan.rb', line 23

def reference
  @reference
end

#review_urlObject

Returns the value of attribute review_url.



25
26
27
# File 'lib/pagseguro/subscription_plan.rb', line 25

def review_url
  @review_url
end

#senderObject

Returns the value of attribute sender.



28
29
30
# File 'lib/pagseguro/subscription_plan.rb', line 28

def sender
  @sender
end

#trial_durationObject

Returns the value of attribute trial_duration.



21
22
23
# File 'lib/pagseguro/subscription_plan.rb', line 21

def trial_duration
  @trial_duration
end

Instance Method Details

#createObject



45
46
47
48
49
50
51
# File 'lib/pagseguro/subscription_plan.rb', line 45

def create
  request = Request.post_xml('pre-approvals/request', API_VERSION, credentials, xml_params)

  Response.new(request, self).serialize

  self
end

#errorsObject

Set errors



31
32
33
# File 'lib/pagseguro/subscription_plan.rb', line 31

def errors
  @errors ||= Errors.new
end

#update_attributes(attrs) ⇒ Object

Update all attributes



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

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

#urlObject



53
54
55
56
57
# File 'lib/pagseguro/subscription_plan.rb', line 53

def url
  return unless code

  "#{PagSeguro.uris[PagSeguro.environment][:site]}v2/pre-approvals/request.html?code=#{code}"
end