Class: Totter::Client
- Inherits:
-
Object
- Object
- Totter::Client
- Includes:
- Activities, Async, Avatars, Choices, Comments, Configuration, Connections, Decisions, Slugs, Stickers, Timelines, Users, Votes
- Defined in:
- lib/totter/client.rb,
lib/totter/client/async.rb,
lib/totter/client/slugs.rb,
lib/totter/client/users.rb,
lib/totter/client/votes.rb,
lib/totter/client/avatars.rb,
lib/totter/client/choices.rb,
lib/totter/client/comments.rb,
lib/totter/client/stickers.rb,
lib/totter/client/decisions.rb,
lib/totter/client/timelines.rb,
lib/totter/client/activities.rb,
lib/totter/client/connections.rb,
lib/totter/client/configuration.rb
Overview
API client for interacting with the Seesaw API
Defined Under Namespace
Modules: Activities, Async, Avatars, Choices, Comments, Configuration, Connections, Decisions, Slugs, Stickers, Timelines, Users, Votes
Constant Summary collapse
- DEFAULTS =
Default parameters for the client
{ :api_scheme => 'https', :api_host => 'api.seesaw.co', :api_version => '1', :result_format => :mashie, :transport => :http }
Constants included from Timelines
Timelines::DEFAULT_TIMELINE_OPTIONS
Constants included from Activities
Activities::DEFAULT_ACTIVITY_OPTIONS
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_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 Votes
Methods included from Users
#follow, #followers, #following, #me, #unfollow, #update_me, #user, #votes
Methods included from Timelines
#flagged_timeline, #friends_timeline, #global_timeline, #hashtag_timeline, #random_timeline_decision, #search_timeline, #sticker_timeline, #user_timeline
Methods included from Stickers
Methods included from Slugs
Methods included from Decisions
#clone_decision, #create_decision, #decision, #decision_analytics, #destroy_decision, #flag_decision, #publish_decision, #unflag_decision
Methods included from Connections
#connections, #find_connection_friends
Methods included from Configuration
Methods included from Comments
#comments, #create_comment, #destroy_comment
Methods included from Choices
#choice, #choice_votes, #create_choice_for_image, #create_choice_upload, #crop_choice, #destroy_choice
Methods included from Avatars
#avatar, #avatars, #create_avatar, #destroy_avatar
Methods included from Async
Methods included from Activities
#activities, #friends_activities, #my_activities
Constructor Details
#initialize(options = {}) ⇒ Client
Initialize a new client.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/totter/client.rb', line 57 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] @client_token = [:client_token] if [:client_token] @transport = [:transport] @result_format = [:result_format] # Include transport transport_module = Totter::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.
23 24 25 |
# File 'lib/totter/client.rb', line 23 def access_token @access_token end |
#api_host ⇒ Object (readonly)
Returns the value of attribute api_host.
25 26 27 |
# File 'lib/totter/client.rb', line 25 def api_host @api_host end |
#api_scheme ⇒ Object (readonly)
Returns the value of attribute api_scheme.
24 25 26 |
# File 'lib/totter/client.rb', line 24 def api_scheme @api_scheme end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
26 27 28 |
# File 'lib/totter/client.rb', line 26 def api_version @api_version end |
#result_format ⇒ Object (readonly)
Returns the value of attribute result_format.
28 29 30 |
# File 'lib/totter/client.rb', line 28 def result_format @result_format end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
27 28 29 |
# File 'lib/totter/client.rb', line 27 def transport @transport end |
Class Method Details
.configure {|options| ... } ⇒ Object
Allows the setting of configuration parameters in a configure block.
50 51 52 |
# File 'lib/totter/client.rb', line 50 def self.configure yield end |
.options ⇒ Object
The current configuration parameters for all clients
40 41 42 |
# File 'lib/totter/client.rb', line 40 def self. @options ||= Hashie::Mash.new(DEFAULTS.dup) end |
.options=(val) ⇒ Object
Sets the current configuration parameters for all clients
45 46 47 |
# File 'lib/totter/client.rb', line 45 def self.(val) @options = val end |
.stubbed? ⇒ Boolean
Returns the current status of HTTP stubbing
104 105 106 |
# File 'lib/totter/client.rb', line 104 def self.stubbed? @@stubbed end |
Instance Method Details
#authenticated? ⇒ Boolean
Is the client has an access token.
92 93 94 |
# File 'lib/totter/client.rb', line 92 def authenticated? @access_token != nil and @access_token.length > 0 end |
#base_url ⇒ String
API base URL.
85 86 87 |
# File 'lib/totter/client.rb', line 85 def base_url "#{@api_scheme}://#{@api_host}/v#{@api_version}/" end |
#ssl? ⇒ Boolean
Is the client using SSL.
99 100 101 |
# File 'lib/totter/client.rb', line 99 def ssl? @api_scheme == 'https' end |