module Sendbird::Client
Constants
- PUBLIC_METHODS
Public Instance Methods
build_url(*args)
click to toggle source
# File lib/sendbird/client.rb, line 28 def build_url(*args) if args.any? new_args = args.dup new_args.insert(0, self.const_get('ENDPOINT')).join('/') else self.const_get('ENDPOINT') end end
Private Instance Methods
api_key(app)
click to toggle source
# File lib/sendbird/client.rb, line 51 def api_key(app) if app if api_key = Sendbird.applications[app] @api_key = api_key else fail NotValidApplication.new(invalid_application_message(app)) end else @api_key = Sendbird.applications[Sendbird.default_app] end @api_key end
api_key_message()
click to toggle source
# File lib/sendbird/client.rb, line 104 def api_key_message 'Plase set up your applications and default_app' end
api_token_request(method:, path:, params:, body:)
click to toggle source
# File lib/sendbird/client.rb, line 87 def api_token_request(method:, path:, params:, body:) conn.send(method) do |req| req.url path, params req.headers['Api-Token'] = @api_key req.headers['Content-Type'] = 'application/json, charset=utf8' req.body = body.to_json if body end end
conn()
click to toggle source
# File lib/sendbird/client.rb, line 64 def conn @conn ||= Faraday.new(url: Sendbird::Configuration::SENDBIRD_ENDPOINT) do |c| c.request :url_encoded c.adapter Faraday.default_adapter end end
get_app_from_params_or_body(params, body)
click to toggle source
# File lib/sendbird/client.rb, line 40 def get_app_from_params_or_body(params, body) app = if params && params.has_key?(:app) params.delete(:app) elsif body && body.has_key?(:app) body.delete(:app) else nil end [params, body, app] end
http_basic_conn()
click to toggle source
# File lib/sendbird/client.rb, line 71 def http_basic_conn @http_basic_conn ||= Faraday.new(url: Sendbird::Configuration::SENDBIRD_ENDPOINT) do |c| c.request :url_encoded c.adapter Faraday.default_adapter c.basic_auth(sendbird_user, sendbird_password) end end
http_basic_message()
click to toggle source
# File lib/sendbird/client.rb, line 108 def http_basic_message 'Please set up you http basic information to be able to execute this requets' end
http_basic_request(method:, path:, params:, body:)
click to toggle source
# File lib/sendbird/client.rb, line 96 def http_basic_request(method:, path:, params:, body:) http_basic_conn.send(method) do |req| req.url path, params req.headers['Content-Type'] = 'application/json, charset=utf8' req.body = body.to_json if body end end
invalid_application_message(app)
click to toggle source
# File lib/sendbird/client.rb, line 112 def invalid_application_message(app) "Application name (#{app}) not found in the configuration, please check your configuration" end
sendbird_password()
click to toggle source
# File lib/sendbird/client.rb, line 83 def sendbird_password Sendbird.password end
sendbird_user()
click to toggle source
# File lib/sendbird/client.rb, line 79 def sendbird_user Sendbird.user end