Class: StreamAPI::Client
- Inherits:
-
Object
- Object
- StreamAPI::Client
- Includes:
- HTTParty
- Defined in:
- lib/streamapi/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#site_id ⇒ Object
Returns the value of attribute site_id.
-
#site_user_id ⇒ Object
Returns the value of attribute site_user_id.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #create_session(username = nil, fme_key = nil, is_video_private = nil, public_host_id = nil, site_user_id = nil) ⇒ Object
- #create_user(username) ⇒ Object
- #get_live_session_status(public_host_id) ⇒ Object
- #get_private_host_id(public_host_id = nil) ⇒ Object
- #get_public_host_id(private_host_id = nil, site_user_id = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #list_live_sessions ⇒ Object
- #list_recorded_videos ⇒ Object
- #list_themes ⇒ Object
- #preprocess_options(options = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/streamapi/client.rb', line 28 def initialize(={}) raise(InvalidApiKeyError, "Missing api_key!") if [:api_key].nil? raise(InvalidSecretKeyError, "Missing secret_key!") if [:secret_key].nil? raise(InvalidSiteIdError, "Missing site_id!") if [:site_id].nil? @api_key = [:api_key] @@api_key = @api_key @secret_key = [:secret_key] @site_id = [:site_id] @username = [:username] if .has_key?('username') return self end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def api_key @api_key end |
#debug ⇒ Object
Returns the value of attribute debug.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def debug @debug end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def secret_key @secret_key end |
#site_id ⇒ Object
Returns the value of attribute site_id.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def site_id @site_id end |
#site_user_id ⇒ Object
Returns the value of attribute site_user_id.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def site_user_id @site_user_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def timeout @timeout end |
#username ⇒ Object
Returns the value of attribute username.
26 27 28 |
# File 'lib/streamapi/client.rb', line 26 def username @username end |
Class Method Details
.sign(options, secret, rid) ⇒ Object
91 92 93 94 |
# File 'lib/streamapi/client.rb', line 91 def self.sign(,secret,rid) .delete_if{ .has_key?('sig') } Digest::MD5.hexdigest(.sort().collect{|v| v[1]}.join+secret+rid.to_s) end |
Instance Method Details
#create_session(username = nil, fme_key = nil, is_video_private = nil, public_host_id = nil, site_user_id = nil) ⇒ Object
51 52 53 54 |
# File 'lib/streamapi/client.rb', line 51 def create_session(username = nil, fme_key = nil, is_video_private = nil, public_host_id = nil, site_user_id = nil) response = self.class.post("/session/create", :query=>({:username=>username, :is_video_private=>is_video_private, :public_host_id=>public_host_id, :site_user_id=>site_user_id})) end |
#create_user(username) ⇒ Object
56 57 58 |
# File 'lib/streamapi/client.rb', line 56 def create_user(username) response = self.class.post("/session/create", :query => ({:username => username})) end |
#get_live_session_status(public_host_id) ⇒ Object
60 61 62 |
# File 'lib/streamapi/client.rb', line 60 def get_live_session_status(public_host_id) response = self.class.post("/session/live", :query => ({:public_host_id => public_host_id})) end |
#get_private_host_id(public_host_id = nil) ⇒ Object
47 48 49 |
# File 'lib/streamapi/client.rb', line 47 def get_private_host_id(public_host_id = nil) response = self.class.get("/host/id/private", :query => ({:public_host_id=>public_host_id})) end |
#get_public_host_id(private_host_id = nil, site_user_id = nil) ⇒ Object
42 43 44 45 |
# File 'lib/streamapi/client.rb', line 42 def get_public_host_id(private_host_id = nil, site_user_id = nil) response = self.class.get("/host/id/public", :query => ({:private_host_id=>private_host_id,:site_user_id=>site_user_id})) end |
#list_live_sessions ⇒ Object
75 76 77 78 |
# File 'lib/streamapi/client.rb', line 75 def list_live_sessions() live_sessions = [] response = self.class.get("/session/live/list", :query => ) end |
#list_recorded_videos ⇒ Object
64 65 66 67 68 |
# File 'lib/streamapi/client.rb', line 64 def list_recorded_videos() recorded_videos = [] response = self.class.get("/video/list", :query => ) # iterate videos end |
#list_themes ⇒ Object
70 71 72 73 |
# File 'lib/streamapi/client.rb', line 70 def list_themes() themes = [] response = self.class.get("/theme/list", :query => ) end |
#preprocess_options(options = nil) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/streamapi/client.rb', line 80 def (=nil) = {} if = {} || .nil? ['key'] = self.api_key rid = (Time.now.to_f * 1000).ceil ['site_user_id'] = self.site_user_id if self.site_user_id ['username'] = self.username if self.username ['sig'] = Client.sign(,self.secret_key, rid) ['rid'] = rid end |