Class: FetchAPI::Order

Inherits:
Base
  • Object
show all
Defined in:
lib/fetchapi/order.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

basic_auth, #initialize

Constructor Details

This class inherits a constructor from FetchAPI::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FetchAPI::Base

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/fetchapi/order.rb', line 4

def attributes
  @attributes
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/fetchapi/order.rb', line 4

def id
  @id
end

Class Method Details

.create(options = {}) ⇒ Object

Creates a new order



27
28
29
# File 'lib/fetchapi/order.rb', line 27

def self.create(options={})
  execute(:post, "/orders/create", :order => options)
end

.find(selector, params = {}) ⇒ Object

– Class Methods ############### –



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fetchapi/order.rb', line 10

def self.find(selector, params={})
  case selector
  when :current
    params.merge!(:filter => "current")
    execute(:get, "/#{pluralized_class_name}?#{params.to_params}")[pluralized_class_name].map { |data| new(data) }
  when :manual
    params.merge!(:filter => "manual")
    execute(:get, "/#{pluralized_class_name}?#{params.to_params}")[pluralized_class_name].map { |data| new(data) }
  when :expired
    params.merge!(:filter => "expired")
    execute(:get, "/#{pluralized_class_name}?#{params.to_params}")[pluralized_class_name].map { |data| new(data) }
  else
    super
  end
end

Instance Method Details

#destroyObject

Permanently deletes the order



36
37
38
# File 'lib/fetchapi/order.rb', line 36

def destroy
  delete("/orders/#{id}/delete")
end

#expireObject

Sets the expiration date to Time.now, stopping future downloads



41
42
43
# File 'lib/fetchapi/order.rb', line 41

def expire
  post("/orders/#{id}/expire")
end

#send_email(options = {}) ⇒ Object

Delivers the email containing the download instructions. Optional params:

reset_expiration (true/false):  Reset the order's expiration. Defaults to true.
expiration_date (2009-04-30T15:03:46+00:00): Manually sets the order's expiration date


49
50
51
# File 'lib/fetchapi/order.rb', line 49

def send_email(options={})
  post("/orders/#{id}/send_email", options)
end

#update(options = {}) ⇒ Object

Immediately updates the order with the new parameters



54
55
56
# File 'lib/fetchapi/order.rb', line 54

def update(options={})
  put("/orders/#{id}", :order => options)
end