Class: ColumnApi::EntityResource
- Inherits:
-
Resource
- Object
- Resource
- ColumnApi::EntityResource
show all
- Defined in:
- lib/column_api/resources/entity_resource.rb
Instance Attribute Summary
Attributes inherited from Resource
#client
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Class Method Details
.from_response(response) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/column_api/resources/entity_resource.rb', line 5
def self.from_response(response)
if response["type"] == "PERSON"
PersonEntity.new(response)
else
BusinessEntity.new(response)
end
end
|
Instance Method Details
#create_business(params) ⇒ Object
30
31
32
|
# File 'lib/column_api/resources/entity_resource.rb', line 30
def create_business(params)
BusinessEntity.new post_request("entities/business", body: params).body
end
|
#create_person(params) ⇒ Object
22
23
24
|
# File 'lib/column_api/resources/entity_resource.rb', line 22
def create_person(params)
PersonEntity.new post_request("entities/person", body: params).body
end
|
#delete(entity_id:) ⇒ Object
38
39
40
41
|
# File 'lib/column_api/resources/entity_resource.rb', line 38
def delete(entity_id:)
delete_request("entities/#{entity_id}")
true
end
|
#list(params = {}) ⇒ Object
17
18
19
20
|
# File 'lib/column_api/resources/entity_resource.rb', line 17
def list(params = {})
response = get_request("entities", params: params).body
Collection.from_response(response, key: "entities", type: EntityResource)
end
|
#retrieve(entity_id:) ⇒ Object
13
14
15
|
# File 'lib/column_api/resources/entity_resource.rb', line 13
def retrieve(entity_id:)
EntityResource.from_response get_request("entities/#{entity_id}").body
end
|
#submit_document(entity_id:, params:) ⇒ Object
43
44
45
46
47
|
# File 'lib/column_api/resources/entity_resource.rb', line 43
def submit_document(entity_id:, params:)
EntityResource.from_response(
post_request("entities/#{entity_id}/documents", body: params).body
)
end
|
#update_business(entity_id:, params:) ⇒ Object
34
35
36
|
# File 'lib/column_api/resources/entity_resource.rb', line 34
def update_business(entity_id:, params:)
BusinessEntity.new patch_request("entities/business/#{entity_id}", body: params).body
end
|
#update_person(entity_id:, params:) ⇒ Object
26
27
28
|
# File 'lib/column_api/resources/entity_resource.rb', line 26
def update_person(entity_id:, params:)
PersonEntity.new patch_request("entities/person/#{entity_id}", body: params).body
end
|