Class: FetchAPI::Order
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
-
.create(options = {}) ⇒ Object
Creates a new Order.
-
.find(selector, params = {}) ⇒ Object
Finds an Order or orders based on the specified parameters :all, :current, :manual, :expired, or by ID.
Instance Method Summary collapse
-
#destroy ⇒ Object
Permanently deletes the Order.
-
#downloads(params = {}) ⇒ Object
Returns all the downloads associated with this Order.
-
#expire ⇒ Object
Sets the expiration date to Time.now, stopping future downloads.
-
#send_email(options = {}) ⇒ Object
Delivers the email containing the download instructions.
-
#update(options = {}) ⇒ Object
Immediately updates the Order with the new parameters.
Methods inherited from Base
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
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/fetchapi/order.rb', line 4 def attributes @attributes end |
#id ⇒ Object
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
44 45 46 |
# File 'lib/fetchapi/order.rb', line 44 def self.create(={}) return FetchAPI::Order.new(execute(:post, "/orders/create", :order => )["order"]) end |
.find(selector, params = {}) ⇒ Object
Finds an Order or orders based on the specified parameters :all, :current, :manual, :expired, or by ID
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fetchapi/order.rb', line 12 def self.find(selector, params={}) case selector when :current params.merge!(:filter => "current") orders = execute(:get, "/orders?#{params.to_params}") if orders["orders"].blank? return [] else orders["orders"].map { |data| new(data) } end when :manual params.merge!(:filter => "manual") orders = execute(:get, "/orders?#{params.to_params}") if orders["orders"].blank? return [] else orders["orders"].map { |data| new(data) } end when :expired params.merge!(:filter => "expired") orders = execute(:get, "/orders?#{params.to_params}") if orders["orders"].blank? return [] else orders["orders"].map { |data| new(data) } end else super end end |
Instance Method Details
#destroy ⇒ Object
Permanently deletes the Order
53 54 55 |
# File 'lib/fetchapi/order.rb', line 53 def destroy delete("/orders/#{id}/delete") end |
#downloads(params = {}) ⇒ Object
Returns all the downloads associated with this Order
76 77 78 79 80 81 |
# File 'lib/fetchapi/order.rb', line 76 def downloads(params={}) downloads = get("/orders/#{id}/downloads") if downloads downloads["downloads"].map { |data| FetchAPI::Download.new(data) } end end |
#expire ⇒ Object
Sets the expiration date to Time.now, stopping future downloads
58 59 60 |
# File 'lib/fetchapi/order.rb', line 58 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
66 67 68 |
# File 'lib/fetchapi/order.rb', line 66 def send_email(={}) post("/orders/#{id}/send_email", ) end |
#update(options = {}) ⇒ Object
Immediately updates the Order with the new parameters
71 72 73 |
# File 'lib/fetchapi/order.rb', line 71 def update(={}) self.attributes = put("/orders/#{id}", :order => )["order"] end |