Class: FetchAppAPI::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.
-
#order_items(params = {}) ⇒ Object
Returns all the downloads associated with this Order.
-
#send_email(options = {}) ⇒ Object
Delivers the email containing the download instructions.
- #stats ⇒ Object
-
#update(options = {}) ⇒ Object
Immediately updates the Order with the new parameters.
Methods inherited from Base
basic_auth, can_connect?, #initialize, key, time
Constructor Details
This class inherits a constructor from FetchAppAPI::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FetchAppAPI::Base
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/fetchapp-api-ruby/order.rb', line 4 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/fetchapp-api-ruby/order.rb', line 4 def id @id end |
Class Method Details
.create(options = {}) ⇒ Object
Creates a new Order
44 45 46 |
# File 'lib/fetchapp-api-ruby/order.rb', line 44 def self.create(={}) return FetchAppAPI::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/fetchapp-api-ruby/order.rb', line 12 def self.find(selector, params={}) case selector when :current params.merge!(:filter => "current") orders = execute(:get, "/orders", params) if orders["orders"].nil? || orders["orders"].empty? return [] else orders["orders"].map { |data| new(data) } end when :manual params.merge!(:filter => "manual") orders = execute(:get, "/orders", params) if orders["orders"].nil? || orders["orders"].empty? return [] else orders["orders"].map { |data| new(data) } end when :expired params.merge!(:filter => "expired") orders = execute(:get, "/orders", params) if orders["orders"].nil? || orders["orders"].empty? 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/fetchapp-api-ruby/order.rb', line 53 def destroy delete("/orders/#{id}/delete") end |
#downloads(params = {}) ⇒ Object
Returns all the downloads associated with this Order
85 86 87 88 89 90 |
# File 'lib/fetchapp-api-ruby/order.rb', line 85 def downloads(params={}) downloads = get("/orders/#{id}/downloads") if downloads downloads["downloads"].map { |data| FetchAppAPI::Download.new(data) } end end |
#expire ⇒ Object
Sets the expiration date to Time.now, stopping future downloads
58 59 60 |
# File 'lib/fetchapp-api-ruby/order.rb', line 58 def expire post("/orders/#{id}/expire") end |
#order_items(params = {}) ⇒ Object
Returns all the downloads associated with this Order
76 77 78 79 80 81 |
# File 'lib/fetchapp-api-ruby/order.rb', line 76 def order_items(params={}) order_items = get("/orders/#{id}/order_items") if order_items order_items["order_items"].map { |data| FetchAppAPI::OrderItem.new(data) } end 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/fetchapp-api-ruby/order.rb', line 66 def send_email(={}) post("/orders/#{id}/send_email", ) end |
#stats ⇒ Object
92 93 94 95 96 97 |
# File 'lib/fetchapp-api-ruby/order.rb', line 92 def stats stats = get("/orders/#{id}/stats") if stats FetchAppAPI::Order.new(stats["order"]) end end |
#update(options = {}) ⇒ Object
Immediately updates the Order with the new parameters
71 72 73 |
# File 'lib/fetchapp-api-ruby/order.rb', line 71 def update(={}) self.attributes = put("/orders/#{id}", :order => )["order"] end |