Class: Capgun::Client
- Inherits:
-
Object
- Object
- Capgun::Client
- Includes:
- Connection, Request
- Defined in:
- lib/capgun/client.rb
Overview
Wrapper for the Capgun REST API
Instance Method Summary collapse
-
#account ⇒ Capgun::Account
Fetch account information.
-
#capture(url, options = {}, &block) ⇒ Capgun::Order
Creates a capgun job.
-
#estimate(url, options = {}, &block) ⇒ Capgun::Estimate
Estimates a capgun job cost / availability.
-
#initialize(attrs = {}) ⇒ Capgun::Client
constructor
Initializes a new API object.
-
#order(order_id) ⇒ Capgun::Order
Query the order.
-
#status(job_id) ⇒ Capgun::Job
Query the status of a capture job.
Methods included from Request
Constructor Details
#initialize(attrs = {}) ⇒ Capgun::Client
Initializes a new API object. Accessor attributes are set based on Capgun::Config::VALID_OPTIONS_KEYS
28 29 30 31 32 33 |
# File 'lib/capgun/client.rb', line 28 def initialize(attrs={}) attrs = Capgun..merge(attrs) Config::VALID_OPTIONS_KEYS.each do |key| instance_variable_set("@#{key}".to_sym, attrs[key]) end end |
Instance Method Details
#account ⇒ Capgun::Account
Fetch account information
78 79 80 81 |
# File 'lib/capgun/client.rb', line 78 def account account = get("/v1/account.json") Capgun::Account.new(account['account']) end |
#capture(url, options = {}, &block) ⇒ Capgun::Order
Creates a capgun job
51 52 53 54 55 |
# File 'lib/capgun/client.rb', line 51 def capture(url, = {}, &block) = (, &block) order = post("/v1/orders.json", .merge(:url => url)) Capgun::Order.new(order['order']) end |
#estimate(url, options = {}, &block) ⇒ Capgun::Estimate
Estimates a capgun job cost / availability.
40 41 42 43 44 |
# File 'lib/capgun/client.rb', line 40 def estimate(url, = {}, &block) = (, &block) estimate = post("/v1/orders/estimate.json", .merge(:url => url)) Capgun::Estimate.new(estimate['order']) end |
#order(order_id) ⇒ Capgun::Order
Query the order
61 62 63 64 |
# File 'lib/capgun/client.rb', line 61 def order(order_id) order = get("/v1/orders/#{order_id}.json") Capgun::Order.new(order['order']) end |
#status(job_id) ⇒ Capgun::Job
Query the status of a capture job.
70 71 72 73 |
# File 'lib/capgun/client.rb', line 70 def status(job_id) job = get("/v1/jobs/#{job_id}.json") Capgun::Job.new(job['job']) end |