Class: SimpleTwitter::Client
- Inherits:
-
Object
- Object
- SimpleTwitter::Client
- Defined in:
- lib/simple_twitter/client.rb
Overview
Twitter API Client
Instance Method Summary collapse
-
#delete(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with DELETE method.
-
#delete_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with DELETE method.
-
#get(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with GET method.
-
#get_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with GET method.
-
#initialize(bearer_token: nil, api_key: nil, api_secret_key: nil, access_token: nil, access_token_secret: nil) ⇒ Client
constructor
A new instance of Client.
-
#post(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with POST method.
-
#post_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with POST method.
-
#put(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with PUT method.
-
#put_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with PUT method.
Constructor Details
#initialize(bearer_token: nil, api_key: nil, api_secret_key: nil, access_token: nil, access_token_secret: nil) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/simple_twitter/client.rb', line 20 def initialize(bearer_token: nil, api_key: nil, api_secret_key: nil, access_token: nil, access_token_secret: nil) if bearer_token @bearer_token = bearer_token else @oauth_params = { consumer_key: api_key, consumer_secret: api_secret_key, token: access_token, token_secret: access_token_secret, } end end |
Instance Method Details
#delete(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with DELETE method
|
# File 'lib/simple_twitter/client.rb', line 94
|
#delete_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with DELETE method
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/simple_twitter/client.rb', line 113 %i[get post put delete].each do |m| class_eval <<~EOD, __FILE__, __LINE__ + 1 def #{m}(url, params: {}, json: {}, form: {}) res = #{m}_raw(url, params: params, json: json, form: form) parse_response(res) end def #{m}_raw(url, params: {}, json: {}, form: {}) args = create_http_args(params: params, json: json, form: form) http(:#{m}, url, params).#{m}(url, args) end EOD end |
#get(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with GET method
|
# File 'lib/simple_twitter/client.rb', line 37
|
#get_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with GET method
|
# File 'lib/simple_twitter/client.rb', line 47
|
#post(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with POST method
|
# File 'lib/simple_twitter/client.rb', line 56
|
#post_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with POST method
|
# File 'lib/simple_twitter/client.rb', line 66
|
#put(url, params: {}, json: {}, form: {}) ⇒ Hash
Call Twitter API with PUT method
|
# File 'lib/simple_twitter/client.rb', line 75
|
#put_raw(url, params: {}, json: {}, form: {}) ⇒ HTTP::Response
Call Twitter API with PUT method
|
# File 'lib/simple_twitter/client.rb', line 85
|