Class: Officevibe::Client
- Inherits:
-
Object
- Object
- Officevibe::Client
- Defined in:
- lib/officevibe/client.rb
Constant Summary collapse
- OFFICEVIBE_URL =
"https://app.officevibe.com"- MANAGEABLE_GROUPS_PATH =
"/groups/manageable"- ENGAGEMENT_REPORT_PATH =
"/report/engagement"- AUTH_TOKEN_COOKIE =
"officevibe.auth"
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
readonly
Returns the value of attribute auth_token.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #get_engagement_report(group_id) ⇒ Object
- #get_groups ⇒ Object
-
#initialize(auth_token) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(auth_token) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 |
# File 'lib/officevibe/client.rb', line 14 def initialize(auth_token) @auth_token = auth_token @connection = Faraday.new url: OFFICEVIBE_URL, headers: headers do |conn| conn.response :json, :content_type => /\bjson$/ conn.adapter Faraday.default_adapter end end |
Instance Attribute Details
#auth_token ⇒ Object (readonly)
Returns the value of attribute auth_token.
5 6 7 |
# File 'lib/officevibe/client.rb', line 5 def auth_token @auth_token end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/officevibe/client.rb', line 5 def connection @connection end |
Instance Method Details
#get_engagement_report(group_id) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/officevibe/client.rb', line 29 def get_engagement_report(group_id) get(ENGAGEMENT_REPORT_PATH, groupId: group_id) .body["data"] .deep_transform_keys(&:underscore) .with_indifferent_access end |
#get_groups ⇒ Object
22 23 24 25 26 27 |
# File 'lib/officevibe/client.rb', line 22 def get_groups get(MANAGEABLE_GROUPS_PATH) .body["result"] .map { |obj| obj.deep_transform_keys(&:underscore) } .map(&:with_indifferent_access) end |