Class: Lapse::Client
- Inherits:
-
Object
- Object
- Lapse::Client
- Includes:
- Clips, Configuration, Frames, GlobalTimelines, 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,
lib/lapse/client/global_timelines.rb
Overview
API client for interacting with the Seesaw API
Defined Under Namespace
Modules: Clips, Configuration, Frames, GlobalTimelines, 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_likes_timeline, #user_timeline
Methods included from Users
#authenticate, #badges, #block, #follow, #followers, #following, #me, #unfollow, #update_me, #user
Methods included from GlobalTimelines
#featured_timeline, #global_timeline
Methods included from Frames
#create_frame, #crop_frame, #destroy_frame
Methods included from Configuration
Methods included from Clips
#all_clips, #clip, #create_clip, #destroy_clip, #featured_clips, #flag_clip, #modify_frames, #publish_clip, #submit_frames, #unflag_clip, #update_clip
Constructor Details
#initialize(options = {}) ⇒ Client
Initialize a new client.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/lapse/client.rb', line 52 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.
16 17 18 |
# File 'lib/lapse/client.rb', line 16 def access_token @access_token end |
#api_host ⇒ Object (readonly)
Returns the value of attribute api_host.
18 19 20 |
# File 'lib/lapse/client.rb', line 18 def api_host @api_host end |
#api_prefix ⇒ Object (readonly)
Returns the value of attribute api_prefix.
19 20 21 |
# File 'lib/lapse/client.rb', line 19 def api_prefix @api_prefix end |
#api_scheme ⇒ Object (readonly)
Returns the value of attribute api_scheme.
17 18 19 |
# File 'lib/lapse/client.rb', line 17 def api_scheme @api_scheme end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
20 21 22 |
# File 'lib/lapse/client.rb', line 20 def api_version @api_version end |
#result_format ⇒ Object (readonly)
Returns the value of attribute result_format.
22 23 24 |
# File 'lib/lapse/client.rb', line 22 def result_format @result_format end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
21 22 23 |
# File 'lib/lapse/client.rb', line 21 def transport @transport end |
Class Method Details
.configure {|options| ... } ⇒ Object
Allows the setting of configuration parameters in a configure block.
45 46 47 |
# File 'lib/lapse/client.rb', line 45 def self.configure yield end |
.options ⇒ Object
The current configuration parameters for all clients
35 36 37 |
# File 'lib/lapse/client.rb', line 35 def self. @options ||= Hashie::Mash.new(DEFAULTS.dup) end |
.options=(val) ⇒ Object
Sets the current configuration parameters for all clients
40 41 42 |
# File 'lib/lapse/client.rb', line 40 def self.(val) @options = val end |
.stubbed? ⇒ Boolean
Returns the current status of HTTP stubbing
100 101 102 |
# File 'lib/lapse/client.rb', line 100 def self.stubbed? @@stubbed end |
Instance Method Details
#authenticated? ⇒ Boolean
Is the client has an access token.
88 89 90 |
# File 'lib/lapse/client.rb', line 88 def authenticated? @access_token != nil and @access_token.length > 0 end |
#base_url ⇒ String
API base URL.
81 82 83 |
# File 'lib/lapse/client.rb', line 81 def base_url "#{@api_scheme}://#{@api_host}/#{@api_prefix}/v#{@api_version}/" end |
#ssl? ⇒ Boolean
Is the client using SSL.
95 96 97 |
# File 'lib/lapse/client.rb', line 95 def ssl? @api_scheme == 'https' end |