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
27 28 29 30 31 32 |
# File 'lib/capgun/client.rb', line 27 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
77 78 79 80 |
# File 'lib/capgun/client.rb', line 77 def account account = get("/v1/account.json") Capgun::Account.new(account['account']) end |
#capture(url, options = {}, &block) ⇒ Capgun::Order
Creates a capgun job
50 51 52 53 54 |
# File 'lib/capgun/client.rb', line 50 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.
39 40 41 42 43 |
# File 'lib/capgun/client.rb', line 39 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
60 61 62 63 |
# File 'lib/capgun/client.rb', line 60 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.
69 70 71 72 |
# File 'lib/capgun/client.rb', line 69 def status(job_id) job = get("/v1/jobs/#{job_id}.json") Capgun::Job.new(job['job']) end |