Class: Audiobank::Account
- Inherits:
-
Object
- Object
- Audiobank::Account
- Includes:
- HTTParty
- Defined in:
- lib/audiobank/account.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #default_options ⇒ Object
- #document(id) ⇒ Object
- #documents ⇒ Object
- #get(url, &block) ⇒ Object
-
#initialize(token) ⇒ Account
constructor
A new instance of Account.
- #post(url, attributes = {}, &block) ⇒ Object
- #process_response(response, &block) ⇒ Object
Constructor Details
#initialize(token) ⇒ Account
Returns a new instance of Account.
11 12 13 |
# File 'lib/audiobank/account.rb', line 11 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
9 10 11 |
# File 'lib/audiobank/account.rb', line 9 def token @token end |
Instance Method Details
#default_options ⇒ Object
15 16 17 |
# File 'lib/audiobank/account.rb', line 15 def { :query => { :auth_token => token } } end |
#document(id) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/audiobank/account.rb', line 35 def document(id) Audiobank::Client.logger.info "Request document information : #{id}" get "/documents/#{id}.json" do |response| Audiobank::Document.new(response) if response.code == 200 end end |
#documents ⇒ Object
42 43 44 |
# File 'lib/audiobank/account.rb', line 42 def documents @documents ||= Audiobank::Documents.new(self) end |
#get(url, &block) ⇒ Object
19 20 21 |
# File 'lib/audiobank/account.rb', line 19 def get(url, &block) process_response self.class.get(url, ), &block end |
#post(url, attributes = {}, &block) ⇒ Object
23 24 25 |
# File 'lib/audiobank/account.rb', line 23 def post(url, attributes = {}, &block) process_response self.class.post(url, .merge(:body => attributes.to_json)), &block end |
#process_response(response, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/audiobank/account.rb', line 27 def process_response(response, &block) if block_given? yield response else response end end |