Class: AirbnbApi::Client
- Inherits:
-
Object
- Object
- AirbnbApi::Client
- Defined in:
- lib/airbnb_api/client.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#oauth_token ⇒ Object
readonly
Returns the value of attribute oauth_token.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
Instance Method Summary collapse
- #adapter ⇒ Object
- #base_url ⇒ Object
- #http ⇒ Object
-
#initialize(id:, secret: nil, oauth_token: nil) ⇒ Client
constructor
A new instance of Client.
- #listings ⇒ Object
- #oauth_token? ⇒ Boolean
- #tokens ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(id:, secret: nil, oauth_token: nil) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/airbnb_api/client.rb', line 6 def initialize(id:, secret: nil, oauth_token: nil) @id = id @secret = secret @oauth_token = oauth_token end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/airbnb_api/client.rb', line 5 def id @id end |
#oauth_token ⇒ Object (readonly)
Returns the value of attribute oauth_token.
5 6 7 |
# File 'lib/airbnb_api/client.rb', line 5 def oauth_token @oauth_token end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
5 6 7 |
# File 'lib/airbnb_api/client.rb', line 5 def secret @secret end |
Instance Method Details
#adapter ⇒ Object
20 21 22 |
# File 'lib/airbnb_api/client.rb', line 20 def adapter @adapter ||= Faraday.default_adapter end |
#base_url ⇒ Object
16 17 18 |
# File 'lib/airbnb_api/client.rb', line 16 def base_url 'https://api.airbnb.com' end |
#http ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/airbnb_api/client.rb', line 24 def http @http ||= Faraday.new(url: base_url) do |faraday| faraday.headers = headers faraday.request :url_encoded faraday.response :json faraday.use AirbnbApi::Util::ErrorHandling faraday.adapter adapter end end |
#listings ⇒ Object
50 51 52 |
# File 'lib/airbnb_api/client.rb', line 50 def listings AirbnbApi::Service::Listing.new(self) end |
#oauth_token? ⇒ Boolean
46 47 48 |
# File 'lib/airbnb_api/client.rb', line 46 def oauth_token? @oauth_token != nil end |
#tokens ⇒ Object
54 55 56 57 |
# File 'lib/airbnb_api/client.rb', line 54 def tokens return AirbnbApi::Service::Token.new(self) if AirbnbApi::Service::Token.can_use_client?(self) raise AirbnbApi::Errors::InvalidClient end |
#version ⇒ Object
12 13 14 |
# File 'lib/airbnb_api/client.rb', line 12 def version @version ||= 'v2' end |