Class: FastSpring::PrivateApiBase
- Inherits:
-
Object
- Object
- FastSpring::PrivateApiBase
- Includes:
- HTTParty
- Defined in:
- lib/fastspring-saasy/private_api_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#customer ⇒ Object
readonly
Returns a customer object.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(reference) ⇒ PrivateApiBase
constructor
A new instance of PrivateApiBase.
- #reference ⇒ Object
- #referrer ⇒ Object
- #search(query) ⇒ Object
- #source_campaign ⇒ Object
- #source_key ⇒ Object
- #source_name ⇒ Object
-
#status ⇒ Object
Returns the current status.
-
#status_changed ⇒ Object
When the status was last changed.
Constructor Details
#initialize(reference) ⇒ PrivateApiBase
Returns a new instance of PrivateApiBase.
10 11 12 13 14 15 16 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 10 def initialize(reference) @auth = {:username => FastSpring::Account.fetch(:username), :password => FastSpring::Account.fetch(:password)} @company = FastSpring::Account.fetch(:company) @reference = reference @ssl_ca_file = FastSpring::Account.fetch(:ssl_ca_file) end |
Instance Attribute Details
#customer ⇒ Object (readonly)
Returns a customer object
8 9 10 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 8 def customer @customer end |
Class Method Details
.find(reference) ⇒ Object
18 19 20 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 18 def self.find(reference) self.new(reference).find end |
.search(query = "") ⇒ Object
22 23 24 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 22 def self.search(query="") self.new("").search(query) end |
Instance Method Details
#reference ⇒ Object
36 37 38 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 36 def reference @reference end |
#referrer ⇒ Object
50 51 52 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 50 def referrer value_for('referrer') end |
#search(query) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 26 def search(query) response = self.class.get("/company/#{@company}/orders/search?query=#{CGI::escape(query)}", :basic_auth => @auth, :ssl_ca_file => @ssl_ca_file) order_response = response.parsed_response['orders']['order'] return [] if order_response.nil? order_response.map do |order| Order.new("").build_from(order) end end |
#source_campaign ⇒ Object
62 63 64 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 62 def source_campaign value_for('sourceCampaign') end |
#source_key ⇒ Object
58 59 60 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 58 def source_key value_for('sourceKey') end |
#source_name ⇒ Object
54 55 56 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 54 def source_name value_for('sourceName') end |
#status ⇒ Object
Returns the current status
41 42 43 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 41 def status value_for('status') end |
#status_changed ⇒ Object
When the status was last changed
46 47 48 |
# File 'lib/fastspring-saasy/private_api_base.rb', line 46 def status_changed DateTime.parse(value_for('statusChanged')) end |