Class: PagSeguro::Subscription
- Inherits:
-
Object
- Object
- PagSeguro::Subscription
- Defined in:
- lib/pagseguro/subscription.rb,
lib/pagseguro/subscription/response.rb,
lib/pagseguro/subscription/request_serializer.rb,
lib/pagseguro/subscription/response_serializer.rb
Overview
It lets you create a subscription without going through PagSeguro screens.
Defined Under Namespace
Classes: RequestSerializer, Response, ResponseSerializer
Constant Summary collapse
- API_VERSION =
:v2
- TEN_DAYS_IN_SECONDS =
864_000
Instance Attribute Summary collapse
-
#charge ⇒ Object
Set the charge.
-
#code ⇒ Object
The code of a created to the subscription, must be saved.
-
#date ⇒ Object
Set the date.
-
#last_event_date ⇒ Object
Set the last event date.
-
#name ⇒ Object
Set the name.
-
#payment_method ⇒ Object
Get the payment method.
-
#plan ⇒ Object
Set the plan.
-
#reference ⇒ Object
Set the reference.
-
#sender ⇒ Object
Get the sender.
-
#status ⇒ Object
Set the status.
-
#tracker ⇒ Object
Set the tracker.
Attributes included from Extensions::Credentiable
Class Method Summary collapse
-
.find_by_code(code, options = {}) ⇒ Object
Find subscription by subscription code.
-
.find_by_notification_code(code, options = {}) ⇒ Object
Find subscription by notification code.
- .load_from_xml(xml) ⇒ Object
- .search_by_date_interval(options = {}) ⇒ Object
- .search_by_days_interval(options = {}) ⇒ Object
Instance Method Summary collapse
Methods included from Extensions::EnsureType
Methods included from Extensions::MassAssignment
Instance Attribute Details
#charge ⇒ Object
Set the charge
27 28 29 |
# File 'lib/pagseguro/subscription.rb', line 27 def charge @charge end |
#code ⇒ Object
The code of a created to the subscription, must be saved
42 43 44 |
# File 'lib/pagseguro/subscription.rb', line 42 def code @code end |
#date ⇒ Object
Set the date
15 16 17 |
# File 'lib/pagseguro/subscription.rb', line 15 def date @date end |
#last_event_date ⇒ Object
Set the last event date
24 25 26 |
# File 'lib/pagseguro/subscription.rb', line 24 def last_event_date @last_event_date end |
#name ⇒ Object
Set the name
12 13 14 |
# File 'lib/pagseguro/subscription.rb', line 12 def name @name end |
#payment_method ⇒ Object
Get the payment method
39 40 41 |
# File 'lib/pagseguro/subscription.rb', line 39 def payment_method @payment_method end |
#plan ⇒ Object
Set the plan
30 31 32 |
# File 'lib/pagseguro/subscription.rb', line 30 def plan @plan end |
#reference ⇒ Object
Set the reference
33 34 35 |
# File 'lib/pagseguro/subscription.rb', line 33 def reference @reference end |
#sender ⇒ Object
Get the sender
36 37 38 |
# File 'lib/pagseguro/subscription.rb', line 36 def sender @sender end |
#status ⇒ Object
Set the status
21 22 23 |
# File 'lib/pagseguro/subscription.rb', line 21 def status @status end |
#tracker ⇒ Object
Set the tracker
18 19 20 |
# File 'lib/pagseguro/subscription.rb', line 18 def tracker @tracker end |
Class Method Details
.find_by_code(code, options = {}) ⇒ Object
Find subscription by subscription code
74 75 76 |
# File 'lib/pagseguro/subscription.rb', line 74 def self.find_by_code(code, ={}) load_from_response send_request("pre-approvals/#{code}", [:credentials]) end |
.find_by_notification_code(code, options = {}) ⇒ Object
Find subscription by notification code
69 70 71 |
# File 'lib/pagseguro/subscription.rb', line 69 def self.find_by_notification_code(code, ={}) load_from_response send_request("pre-approvals/notifications/#{code}", [:credentials]) end |
.load_from_xml(xml) ⇒ Object
101 102 103 |
# File 'lib/pagseguro/subscription.rb', line 101 def self.load_from_xml(xml) new ResponseSerializer.new(xml).serialize_from_search end |
.search_by_date_interval(options = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pagseguro/subscription.rb', line 89 def self.search_by_date_interval(={}) # Default options = { starts_at: Time.now, ends_at: Time.now - TEN_DAYS_IN_SECONDS, per_page: 50, page: 0 }.merge() SubscriptionSearch.new('pre-approvals', ) end |
.search_by_days_interval(options = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/pagseguro/subscription.rb', line 78 def self.search_by_days_interval(={}) # Default options = { interval: 30, per_page: 50, page: 0 }.merge() SubscriptionSearch.new('pre-approvals/notifications', ) end |
Instance Method Details
#create ⇒ Object
58 59 60 61 62 |
# File 'lib/pagseguro/subscription.rb', line 58 def create request = Request.post_xml('pre-approvals', nil, credentials, xml_params, ) Response.new(request, self).serialize self end |
#errors ⇒ Object
64 65 66 |
# File 'lib/pagseguro/subscription.rb', line 64 def errors @errors ||= Errors.new end |
#update_attributes(attrs) ⇒ Object
54 55 56 |
# File 'lib/pagseguro/subscription.rb', line 54 def update_attributes(attrs) attrs.each {|name, value| send("#{name}=", value) } end |