class Officevibe::Client

Constants

ENGAGEMENT_REPORT_PATH
MANAGEABLE_GROUPS_PATH
OFFICEVIBE_URL

Attributes

auth_token[R]
connection[R]

Public Class Methods

new(auth_token) click to toggle source
# File lib/officevibe/client.rb, line 21
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.response :raise_error
    conn.use Officevibe::ClientMiddleware
    conn.adapter Faraday.default_adapter
  end
end

Public Instance Methods

get_engagement_report(group_id) click to toggle source
# File lib/officevibe/client.rb, line 38
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() click to toggle source
# File lib/officevibe/client.rb, line 31
def get_groups
  get(MANAGEABLE_GROUPS_PATH)
    .body["result"]
    .map { |obj| obj.deep_transform_keys(&:underscore) }
    .map(&:with_indifferent_access)
end

Private Instance Methods

headers() click to toggle source
# File lib/officevibe/client.rb, line 47
def headers
  { "Cookie" => { AUTH_TOKEN_COOKIE => auth_token }.to_query }
end