Class: Catch::Client
- Inherits:
-
Object
- Object
- Catch::Client
- Defined in:
- lib/catch/client.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#connection ⇒ Faraday::Connection
Raw HTTP connection, either Faraday::Connection.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#media_connection ⇒ Faraday::Connection
Raw HTTP connection, either Faraday::Connection.
Methods included from User
Methods included from Tag
Methods included from Search
Methods included from Place
#add_place, #delete_place, #modify_place, #place, #places
Methods included from Note
#add_note, #delete_note, #modify_note, #note, #notes
Methods included from Media
#add_media, #delete_media, #media
Methods included from Comment
#add_comment, #comment, #comments, #delete_comment, #modify_comment
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 |
# File 'lib/catch/client.rb', line 13 def initialize(={}) @api_url = "https://api.catch.com/v2" @username = [:username] || Catch.username password = [:password] || Catch.password connection.basic_auth(@username, password) media_connection.basic_auth(@username, password) end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
11 12 13 |
# File 'lib/catch/client.rb', line 11 def api_url @api_url end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
11 12 13 |
# File 'lib/catch/client.rb', line 11 def username @username end |
Instance Method Details
#connection ⇒ Faraday::Connection
Raw HTTP connection, either Faraday::Connection
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/catch/client.rb', line 24 def connection @connection ||= Faraday.new(:url => @api_url, :headers => default_headers) do |builder| builder.request :multipart builder.request :url_encoded builder.request :json builder.adapter Faraday.default_adapter builder.use Faraday::Response::Mashify builder.use Faraday::Response::ParseJson end end |
#media_connection ⇒ Faraday::Connection
Raw HTTP connection, either Faraday::Connection
media_connection is used for calls which do not return JSON data.
40 41 42 43 44 45 46 47 |
# File 'lib/catch/client.rb', line 40 def media_connection @media_connection ||= Faraday.new(:url => @api_url, :headers => default_headers) do |builder| builder.request :multipart builder.request :url_encoded builder.adapter Faraday.default_adapter builder.use Faraday::Response::Mashify end end |