Class: Core::Client::V1::Base
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Core::Client::V1::Base
show all
- Defined in:
- lib/core/client/v1/base.rb
Class Method Summary
collapse
Class Method Details
.all ⇒ Object
18
19
20
|
# File 'lib/core/client/v1/base.rb', line 18
def all
where({})
end
|
.client ⇒ Object
11
12
13
14
15
16
|
# File 'lib/core/client/v1/base.rb', line 11
def client
@client ||= RestClient::Resource.new(
"#{ENV['CORE_URL'] || 'https://core.able.co'}/api",
headers: { "Authorization" => "Bearer #{ENV['CORE_API_TOKEN']}" }
)
end
|
.count ⇒ Object
30
31
32
|
# File 'lib/core/client/v1/base.rb', line 30
def count
all.count
end
|
.find(id) ⇒ Object
34
35
36
|
# File 'lib/core/client/v1/base.rb', line 34
def find(id)
new(get("#{table_name}/#{id}"))
end
|
.first ⇒ Object
22
23
24
|
# File 'lib/core/client/v1/base.rb', line 22
def first
all.first
end
|
.last ⇒ Object
26
27
28
|
# File 'lib/core/client/v1/base.rb', line 26
def last
all.last
end
|
.where(conditions) ⇒ Object
38
39
40
41
42
|
# File 'lib/core/client/v1/base.rb', line 38
def where(conditions)
get(table_name, conditions).map do |item|
new(item)
end
end
|