Class: Billy::Service
Instance Attribute Summary
Attributes inherited from BaseModel
Class Method Summary collapse
- .create(atech_identity, service) ⇒ Object
- .find(field, data) ⇒ Object
- .find_for_identity(ati_key) ⇒ Object
- .validate_label(label) ⇒ Object
Instance Method Summary collapse
- #address? ⇒ Boolean
-
#change_label(new_label) ⇒ Object
Change the label associated with a service.
-
#change_user(atech_identity_key) ⇒ Object
Change the user associated with this service to the given aTech identity key.
-
#create_invoice(options = {}) ⇒ Object
Create a new invoice for the service and return the new invoice object.
-
#create_session(start_path = nil, return_url = nil, auto_return_after_payment = false) ⇒ Object
Create a new login session and return a URL which can be used to log the user into the billing application.
-
#create_signup_token(product, package) ⇒ Object
Create a new signup token for another application.
-
#invoice(number) ⇒ Object
Return the invoice for this service.
-
#list ⇒ Object
Get a paginated list of all Billy services.
-
#update(properties) ⇒ Object
Update an existing service by passing new properties.
Methods inherited from BaseModel
Constructor Details
This class inherits a constructor from Billy::BaseModel
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Billy::BaseModel
Class Method Details
.create(atech_identity, service) ⇒ Object
77 78 79 80 |
# File 'lib/billy/service.rb', line 77 def self.create(atech_identity, service) attributes = Billy::Request.request('services/create', :service => service, :atech_identity_key => atech_identity) attributes.is_a?(Hash) ? self.new(attributes) : nil end |
.find(field, data) ⇒ Object
68 69 70 71 |
# File 'lib/billy/service.rb', line 68 def self.find(field, data) attributes = Billy::Request.request('services/info', :field => field, :data => data) attributes.is_a?(Hash) ? self.new(attributes) : nil end |
Instance Method Details
#address? ⇒ Boolean
63 64 65 66 |
# File 'lib/billy/service.rb', line 63 def address? return false if self.address.first.nil? || self.address.last.nil? return true end |
#change_label(new_label) ⇒ Object
Change the label associated with a service
41 42 43 44 45 46 47 48 49 |
# File 'lib/billy/service.rb', line 41 def change_label(new_label) request = Billy::Request.request('services/change_label', :id => @attributes['id'], :label => new_label) if request @attributes = request return true else return false end end |
#change_user(atech_identity_key) ⇒ Object
Change the user associated with this service to the given aTech identity key
30 31 32 33 34 35 36 37 38 |
# File 'lib/billy/service.rb', line 30 def change_user(atech_identity_key) request = Billy::Request.request('services/change_user', :id => @attributes['id'], :atech_identity_key => atech_identity_key) if request @attributes = request return true else return false end end |
#create_invoice(options = {}) ⇒ Object
Create a new invoice for the service and return the new invoice object
52 53 54 55 |
# File 'lib/billy/service.rb', line 52 def create_invoice( = {}) attributes = Billy::Request.request('invoices/create', :service => @attributes['id'], :invoice => ) attributes.is_a?(Hash) ? Billy::Invoice.new(attributes) : nil end |
#create_session(start_path = nil, return_url = nil, auto_return_after_payment = false) ⇒ Object
Create a new login session and return a URL which can be used to log the user into the billing application
17 18 19 20 |
# File 'lib/billy/service.rb', line 17 def create_session(start_path = nil, return_url = nil, auto_return_after_payment = false) session = Billy::Request.request('services/create_session', :id => @attributes['id'], :start_path => start_path, :return_url => return_url, :auto_return_after_payment => auto_return_after_payment) session ? [Billy.host, 'start', session['token']].join('/') : false end |
#create_signup_token(product, package) ⇒ Object
Create a new signup token for another application
23 24 25 26 27 |
# File 'lib/billy/service.rb', line 23 def create_signup_token(product, package) return false if product.nil? || package.nil? token = Billy::Request.request('services/create_signup_token', :id => @attributes['id'], :product => product, :package => package) token ? token['url'] : false end |
#invoice(number) ⇒ Object
Return the invoice for this service
58 59 60 61 |
# File 'lib/billy/service.rb', line 58 def invoice(number) attributes = Billy::Request.request('invoices/info', :invoice => number, :service => @attributes['id']) attributes.is_a?(Hash) ? Billy::Invoice.new(attributes) : nil end |