Class: Moip::Subscription
- Includes:
- HTTParty, Header
- Defined in:
- lib/moip/models/subscription.rb
Instance Attribute Summary collapse
-
#alerts ⇒ Object
Returns the value of attribute alerts.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#code ⇒ Object
Returns the value of attribute code.
-
#creation_date ⇒ Object
Returns the value of attribute creation_date.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
-
#invoice ⇒ Object
Returns the value of attribute invoice.
-
#message ⇒ Object
Returns the value of attribute message.
-
#next_invoice_date ⇒ Object
Returns the value of attribute next_invoice_date.
-
#plan ⇒ Object
Returns the value of attribute plan.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subscriptions ⇒ Object
Returns the value of attribute subscriptions.
Instance Method Summary collapse
- #activate ⇒ Object
- #attributes ⇒ Object
- #create ⇒ Object
-
#create_with_costumer ⇒ Object
To Do.
- #find(code) ⇒ Object
- #invoices ⇒ Object
- #load ⇒ Object
- #suspend ⇒ Object
- #update_amount(plan, new_amount) ⇒ Object
- #update_next_invoice(plan, next_invoice_date) ⇒ Object
- #update_plan(new_plan) ⇒ Object
Methods included from Header
#auth, #base_url, #default_header
Methods inherited from Model
build, #set_parameters, #to_json
Instance Attribute Details
#alerts ⇒ Object
Returns the value of attribute alerts.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def alerts @alerts end |
#amount ⇒ Object
Returns the value of attribute amount.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def amount @amount end |
#code ⇒ Object
Returns the value of attribute code.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def code @code end |
#creation_date ⇒ Object
Returns the value of attribute creation_date.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def creation_date @creation_date end |
#customer ⇒ Object
Returns the value of attribute customer.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def customer @customer end |
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def errors @errors end |
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def expiration_date @expiration_date end |
#invoice ⇒ Object
Returns the value of attribute invoice.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def invoice @invoice end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def @message end |
#next_invoice_date ⇒ Object
Returns the value of attribute next_invoice_date.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def next_invoice_date @next_invoice_date end |
#plan ⇒ Object
Returns the value of attribute plan.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def plan @plan end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def status @status end |
#subscriptions ⇒ Object
Returns the value of attribute subscriptions.
6 7 8 |
# File 'lib/moip/models/subscription.rb', line 6 def subscriptions @subscriptions end |
Instance Method Details
#activate ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/moip/models/subscription.rb', line 87 def activate if self.status != "activate" self.status = "activate" self.class.put(base_url(:subscriptions, :code => self.code, :status => "activate"), default_header).parsed_response true end end |
#attributes ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/moip/models/subscription.rb', line 13 def attributes { "code" => code, "amount" => amount, "plan" => plan, "customer" => customer } end |
#create ⇒ Object
63 64 65 |
# File 'lib/moip/models/subscription.rb', line 63 def create self.class.post(base_url(:subscriptions), default_header(self.to_json)).parsed_response end |
#create_with_costumer ⇒ Object
To Do
68 69 70 71 |
# File 'lib/moip/models/subscription.rb', line 68 def create_with_costumer # To Do: will not be developed this feature right now, if you # want to fork and develop this feature, be welcome. end |
#find(code) ⇒ Object
74 75 76 77 |
# File 'lib/moip/models/subscription.rb', line 74 def find code response = self.class.get(base_url(:subscriptions, :code => code), default_header).parsed_response self.set_parameters response unless response.nil? end |
#invoices ⇒ Object
52 53 54 |
# File 'lib/moip/models/subscription.rb', line 52 def invoices @invoices ||= Moip::Invoice.build(:subscription_code => self.code).invoices end |
#load ⇒ Object
57 58 59 60 |
# File 'lib/moip/models/subscription.rb', line 57 def load list = self.class.get(base_url(:subscriptions), default_header).parsed_response self.subscriptions = list["subscriptions"] end |
#suspend ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/moip/models/subscription.rb', line 79 def suspend if self.status != "suspend" self.status = "suspend" self.class.put(base_url(:subscriptions, :code => self.code, :status => "suspend"), default_header).parsed_response true end end |
#update_amount(plan, new_amount) ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/moip/models/subscription.rb', line 112 def update_amount plan, new_amount hash = {} self.find self.code hash[:plan] = { :code => plan } hash[:amount] = new_amount self.class.put(base_url(:subscriptions, :code => self.code), default_header(hash.to_json)).parsed_response end |
#update_next_invoice(plan, next_invoice_date) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/moip/models/subscription.rb', line 104 def update_next_invoice plan, next_invoice_date hash = {} hash[:plan] = { :code => plan } hash[:next_invoice_date] = next_invoice_date self.class.put(base_url(:subscriptions, :code => self.code), default_header(hash.to_json)).parsed_response end |
#update_plan(new_plan) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/moip/models/subscription.rb', line 96 def update_plan new_plan hash = {} hash[:plan] = { :code => new_plan } self.class.put(base_url(:subscriptions, :code => self.code), default_header(hash.to_json)).parsed_response end |