Class: Pingboard::Client
- Inherits:
-
Object
- Object
- Pingboard::Client
- Defined in:
- lib/pingboard/client.rb
Constant Summary collapse
- URL_HOSTNAME =
'https://app.pingboard.com'.freeze
- URL_API_VERSION_PATH =
'/api/v2'.freeze
- URL_SEARCH_USERS_PATH =
'/search/users'.freeze
- URL_USERS_PATH =
'/users'.freeze
- URL_STATUSES_PATH =
'/statuses'.freeze
- URL_STATUS_TYPES_PATH =
'/status_types'.freeze
- URL_OAUTH_TOKEN_PATH =
'/oauth/token'.freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#service_app_id ⇒ Object
Returns the value of attribute service_app_id.
-
#service_app_secret ⇒ Object
Returns the value of attribute service_app_secret.
-
#token_expiration_time ⇒ Object
Returns the value of attribute token_expiration_time.
-
#token_expires_in ⇒ Object
Returns the value of attribute token_expires_in.
Instance Method Summary collapse
-
#initialize(request = Pingboard::Request, options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #search(query, options = {}) ⇒ Object
- #status(status_id, options = {}) ⇒ Object
- #status_types ⇒ Object
- #user(user_id, options = {}) ⇒ Object
- #users(options = {}) ⇒ Object
Constructor Details
#initialize(request = Pingboard::Request, options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 |
# File 'lib/pingboard/client.rb', line 15 def initialize(request=Pingboard::Request, ={}) .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? @token_expiration_time = Time.now @request = request end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
12 13 14 |
# File 'lib/pingboard/client.rb', line 12 def access_token @access_token end |
#connection ⇒ Object
Returns the value of attribute connection.
12 13 14 |
# File 'lib/pingboard/client.rb', line 12 def connection @connection end |
#service_app_id ⇒ Object
Returns the value of attribute service_app_id.
12 13 14 |
# File 'lib/pingboard/client.rb', line 12 def service_app_id @service_app_id end |
#service_app_secret ⇒ Object
Returns the value of attribute service_app_secret.
12 13 14 |
# File 'lib/pingboard/client.rb', line 12 def service_app_secret @service_app_secret end |
#token_expiration_time ⇒ Object
Returns the value of attribute token_expiration_time.
12 13 14 |
# File 'lib/pingboard/client.rb', line 12 def token_expiration_time @token_expiration_time end |
#token_expires_in ⇒ Object
Returns the value of attribute token_expires_in.
12 13 14 |
# File 'lib/pingboard/client.rb', line 12 def token_expires_in @token_expires_in end |
Instance Method Details
#search(query, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pingboard/client.rb', line 24 def search(query, ={}) .merge!(q: query) response = build_request( self, :get, URL_API_VERSION_PATH + URL_SEARCH_USERS_PATH, {'Authorization' => "Bearer #{access_token}" }, nil, ).do JSON.parse(response.body) end |
#status(status_id, options = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pingboard/client.rb', line 61 def status(status_id, ={}) response = build_request( self, :get, URL_API_VERSION_PATH + URL_STATUSES_PATH + "/#{status_id}", {'Authorization' => "Bearer #{access_token}" }, nil, ).do JSON.parse(response.body) end |
#status_types ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/pingboard/client.rb', line 73 def status_types response = build_request( self, :get, URL_API_VERSION_PATH + URL_STATUS_TYPES_PATH, {'Authorization' => "Bearer #{access_token}" }, nil, nil ).do JSON.parse(response.body) end |
#user(user_id, options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pingboard/client.rb', line 49 def user(user_id, ={}) response = build_request( self, :get, URL_API_VERSION_PATH + URL_USERS_PATH + "/#{user_id}", {'Authorization' => "Bearer #{access_token}" }, nil, ).do JSON.parse(response.body) end |
#users(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pingboard/client.rb', line 37 def users(={}) response = build_request( self, :get, URL_API_VERSION_PATH + URL_USERS_PATH, {'Authorization' => "Bearer #{access_token}" }, nil, ).do JSON.parse(response.body) end |