Class: Motivosity::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mvclient/client.rb

Defined Under Namespace

Classes: Request

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



7
8
9
# File 'lib/mvclient/client.rb', line 7

def initialize
  @auth = Auth.new
end

Instance Method Details

#feed(scope = :team, page = 0, comment = true) ⇒ Object

returns feed scope is one of :team, :extended_team, :department, or :company



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/mvclient/client.rb', line 67

def feed(scope = :team, page = 0, comment = true)
  scope_param = case scope
    when :team
      "TEAM"
    when :extended_team
      "EXTM"
    when :department
      "DEPT"
    when :company
      "CMPY"
    else
      scope.to_s
  end
  get "/api/v1/feed", scope: scope_param, page: page, comment: comment
end

#get_announcements(page = 0) ⇒ Object

returns recent announcements



61
62
63
# File 'lib/mvclient/client.rb', line 61

def get_announcements(page = 0)
  get "/api/v1/announcement", pageNo: page
end

#get_balanceObject

returns balances

"cashReceiving" : 39, # money received
"cashGiving"    : 10  # money available to give



45
46
47
# File 'lib/mvclient/client.rb', line 45

def get_balance
  get "/api/v1/usercash"
end

#get_valuesObject

returns a list of Values [

"id" : "39602196-7348-cval-aa03-4f8ef9ce45b8",
"name":  "Customer Experience",
"description": "We aspire to create an awesome customer experience in every interaction with our product and people.",

…, …]



36
37
38
# File 'lib/mvclient/client.rb', line 36

def get_values
  get "/api/v1/companyvalue"
end

#login!(username, password) ⇒ Object



11
12
13
# File 'lib/mvclient/client.rb', line 11

def login!(username, password)
  @auth.login! username, password
end

#logout!Object



15
16
17
# File 'lib/mvclient/client.rb', line 15

def logout!
  @auth.logout!
end

#search_for_user(search_term, ignore_self = true) ⇒ Object

supply a name or part of a name returns a list of matching users [{

"id" => "00000000-0000-user-0000-000000000000",
"fullName" => "Jane Doe",
"avatarUrl" => "user-placeholder.png",
}, ...]


26
27
28
# File 'lib/mvclient/client.rb', line 26

def search_for_user(search_term, ignore_self = true)
  get "/api/v1/usertypeahead", name: search_term, ignoreSelf: ignore_self
end

#send_appreciation!(user_id, opts = {}) ⇒ Object

sends appreciation to another User raises BalanceError if insufficient funds exist



51
52
53
54
55
56
57
58
# File 'lib/mvclient/client.rb', line 51

def send_appreciation!(user_id, opts = {})
  params = { "toUserID" => user_id }
  params["companyValueID"] = opts[:company_value_id] if opts[:company_value_id]
  params["amount"] = opts[:amount] if opts[:amount]
  params["note"] = opts[:note] if opts[:note]
  params["privateAppreciation"] = opts[:private] || false
  put "/api/v1/user/#{user_id}/appreciation", {}, params
end