Class: Recharge::Subscription

Inherits:
Object
  • Object
show all
Extended by:
HTTPRequest::Create, HTTPRequest::Get, HTTPRequest::List, HTTPRequest::Update
Includes:
Persistable
Defined in:
lib/recharge/classes.rb

Constant Summary collapse

PATH =
"/subscriptions".freeze
SINGLE =
"subscription".freeze
COLLECTION =
"subscriptions".freeze

Class Method Summary collapse

Methods included from HTTPRequest::Create

create

Methods included from HTTPRequest::Get

get

Methods included from HTTPRequest::Update

update

Methods included from HTTPRequest::List

list

Methods included from Persistable

#save

Class Method Details

.activate(id) ⇒ Object

Activate a subscription

Arguments

id (Integer)

ID of subscription to cancel

Returns

Recharge::Subscription

The activated subscription

Errors

Recharge::ConnectionError, Recharge::RequestError

If the subscription was already activated a Recharge::RequestError will be raised



559
560
561
562
# File 'lib/recharge/classes.rb', line 559

def self.activate(id)
  id_required!(id)
  instance(POST(join(id, "activate"), :status => "active"))
end

.cancel(id, reason) ⇒ Object

Cancel a subscription

Arguments

id (Integer)

ID of subscription to cancel

reason (String)

Reason for the cancellation

Returns

Recharge::Subscription

The canceled subscription

Errors

Recharge::ConnectionError, Recharge::RequestError

If the subscription was already canceled a Recharge::RequestError will be raised



582
583
584
585
# File 'lib/recharge/classes.rb', line 582

def self.cancel(id, reason)
  id_required!(id)
  instance(POST(join(id, "cancel"), :cancellation_reason => reason))
end

.list(options = nil) ⇒ Object



592
593
594
595
# File 'lib/recharge/classes.rb', line 592

def self.list(options = nil)
  #options[:status] = options[:status].upcase if options[:status]
  super(convert_date_params(options, :created_at, :created_at_max, :updated_at, :updated_at_max))
end

.set_next_charge_date(id, date) ⇒ Object



587
588
589
590
# File 'lib/recharge/classes.rb', line 587

def self.set_next_charge_date(id, date)
  id_required!(id)
  instance(POST(join(id, "set_next_charge_date"), :date => date_param(date)))
end