Class: Rexpense::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



8
9
10
# File 'lib/rexpense/client.rb', line 8

def initialize(token)
  @http = Http.new(token)
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



6
7
8
# File 'lib/rexpense/client.rb', line 6

def http
  @http
end

Instance Method Details

#activitiesObject

Define available endpoints



21
22
23
# File 'lib/rexpense/client.rb', line 21

def activities
  Rexpense::Resources::Activity.new(http)
end

#advancement_devolutionsObject



25
26
27
# File 'lib/rexpense/client.rb', line 25

def advancement_devolutions
  Rexpense::Resources::AdvancementDevolution.new(http)
end

#authenticated?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
# File 'lib/rexpense/client.rb', line 12

def authenticated?
  http.get("/organizations") { |response| response.code == 200 }
rescue RequestError => e
  raise e unless [401, 403].include?(e.code)
  false
end

#pre_expensesObject



29
30
31
# File 'lib/rexpense/client.rb', line 29

def pre_expenses
  Rexpense::Resources::PreExpense.new(http)
end