Class: Lapse::Client
- Inherits:
-
Object
- Object
- Lapse::Client
- Includes:
- Clips, Configuration, Frames, UserTimelines, Users
- Defined in:
- lib/lapse/client.rb,
lib/lapse/client/clips.rb,
lib/lapse/client/likes.rb,
lib/lapse/client/users.rb,
lib/lapse/client/frames.rb,
lib/lapse/client/configuration.rb,
lib/lapse/client/user_timelines.rb
Overview
API client for interacting with the Seesaw API
Defined Under Namespace
Modules: Clips, Configuration, Frames, Likes, UserTimelines, Users
Constant Summary collapse
- DEFAULTS =
Default parameters for the client
{ :api_scheme => 'https', :api_host => 'everlapse.com', :api_version => '1', :api_prefix => 'api', :result_format => :mashie, :transport => :http }
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#api_host ⇒ Object
readonly
Returns the value of attribute api_host.
-
#api_prefix ⇒ Object
readonly
Returns the value of attribute api_prefix.
-
#api_scheme ⇒ Object
readonly
Returns the value of attribute api_scheme.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#result_format ⇒ Object
readonly
Returns the value of attribute result_format.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Class Method Summary collapse
-
.configure {|options| ... } ⇒ Object
Allows the setting of configuration parameters in a configure block.
-
.options ⇒ Object
The current configuration parameters for all clients.
-
.options=(val) ⇒ Object
Sets the current configuration parameters for all clients.
-
.stubbed? ⇒ Boolean
Returns the current status of HTTP stubbing.
Instance Method Summary collapse
-
#authenticated? ⇒ Boolean
Is the client has an access token.
-
#base_url ⇒ String
API base URL.
-
#initialize(options = {}) ⇒ Client
constructor
Initialize a new client.
-
#ssl? ⇒ Boolean
Is the client using SSL.
Methods included from UserTimelines
#user_contributed_timeline, #user_contributors_timeline, #user_likes_timeline, #user_timeline
Methods included from Users
Methods included from Frames
#clip_frames, #create_frame, #destroy_frame
Methods included from Configuration
Methods included from Clips
#accept_frames, #all_clips, #create_clip, #destroy_clip, #featured_clips, #publish_clip
Constructor Details
#initialize(options = {}) ⇒ Client
Initialize a new client.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/lapse/client.rb', line 51 def initialize( = {}) = { :access_token => } if .is_a? String = self.class..merge() # Parse `api_url` option if url = .delete(:api_url) uri = URI.parse(url) [:api_scheme] = uri.scheme [:api_host] = uri.host + (uri.port != 80 && uri.port != 443 ? ":#{uri.port}" : '') end @access_token = [:access_token] if [:access_token] @api_scheme = [:api_scheme] @api_host = [:api_host] @api_version = [:api_version] @api_prefix = [:api_prefix] @client_token = [:client_token] if [:client_token] @transport = [:transport] @result_format = [:result_format] # Include transport transport_module = Lapse::Transport::TRANSPORT_MAP[@transport] raise 'Invalid transport' unless transport_module self.extend transport_module end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
15 16 17 |
# File 'lib/lapse/client.rb', line 15 def access_token @access_token end |
#api_host ⇒ Object (readonly)
Returns the value of attribute api_host.
17 18 19 |
# File 'lib/lapse/client.rb', line 17 def api_host @api_host end |
#api_prefix ⇒ Object (readonly)
Returns the value of attribute api_prefix.
18 19 20 |
# File 'lib/lapse/client.rb', line 18 def api_prefix @api_prefix end |
#api_scheme ⇒ Object (readonly)
Returns the value of attribute api_scheme.
16 17 18 |
# File 'lib/lapse/client.rb', line 16 def api_scheme @api_scheme end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
19 20 21 |
# File 'lib/lapse/client.rb', line 19 def api_version @api_version end |
#result_format ⇒ Object (readonly)
Returns the value of attribute result_format.
21 22 23 |
# File 'lib/lapse/client.rb', line 21 def result_format @result_format end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
20 21 22 |
# File 'lib/lapse/client.rb', line 20 def transport @transport end |
Class Method Details
.configure {|options| ... } ⇒ Object
Allows the setting of configuration parameters in a configure block.
44 45 46 |
# File 'lib/lapse/client.rb', line 44 def self.configure yield end |
.options ⇒ Object
The current configuration parameters for all clients
34 35 36 |
# File 'lib/lapse/client.rb', line 34 def self. ||= Hashie::Mash.new(DEFAULTS.dup) end |
.options=(val) ⇒ Object
Sets the current configuration parameters for all clients
39 40 41 |
# File 'lib/lapse/client.rb', line 39 def self.=(val) = val end |
.stubbed? ⇒ Boolean
Returns the current status of HTTP stubbing
99 100 101 |
# File 'lib/lapse/client.rb', line 99 def self.stubbed? @@stubbed end |
Instance Method Details
#authenticated? ⇒ Boolean
Is the client has an access token.
87 88 89 |
# File 'lib/lapse/client.rb', line 87 def authenticated? @access_token != nil and @access_token.length > 0 end |
#base_url ⇒ String
API base URL.
80 81 82 |
# File 'lib/lapse/client.rb', line 80 def base_url "#{@api_scheme}://#{@api_host}/#{@api_prefix}/v#{@api_version}/" end |
#ssl? ⇒ Boolean
Is the client using SSL.
94 95 96 |
# File 'lib/lapse/client.rb', line 94 def ssl? @api_scheme == 'https' end |