Class: Officevibe::Client

Inherits:
Object
  • Object
show all
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"
"officevibe.auth"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_token) ⇒ Client

Returns a new instance of Client.



21
22
23
24
25
26
27
28
29
# 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

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



12
13
14
# File 'lib/officevibe/client.rb', line 12

def auth_token
  @auth_token
end

#connectionObject (readonly)

Returns the value of attribute connection.



12
13
14
# File 'lib/officevibe/client.rb', line 12

def connection
  @connection
end

Instance Method Details

#get_engagement_report(group_id) ⇒ Object



38
39
40
41
42
43
# 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_groupsObject



31
32
33
34
35
36
# 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