Class: SBF::Client::CommunicateEndpoint
Instance Attribute Summary
#orig_target_class
Instance Method Summary
collapse
#aggregate, #create, #delete, #find, #find_first, #get, #initialize, #save, #update
Instance Method Details
#categories(_ = nil) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/stbaldricks/endpoints/communicate.rb', line 6
def categories(_ = nil)
response = SBF::Client::Api::Request.post_request("#{base_uri}/categories")
parsed_response_body = JSON.parse(response.body).symbolize!
handle_parsed_response(parsed_response_body, response)
end
|
#compose(entity, with = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/stbaldricks/endpoints/communicate.rb', line 27
def compose(entity, with = {})
raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
with = normalize_with(with)
create_data = entity.to_hash
create_data.store(:with, with)
response = SBF::Client::Api::Request.post_request("#{base_uri}/compose", create_data)
error = SBF::Client::ErrorEntity.new(response.body) unless ok?(response)
SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
end
|
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/stbaldricks/endpoints/communicate.rb', line 42
def contacts(category, year, group_type, group_id)
response = SBF::Client::Api::Request.post_request(
"#{base_uri}/contacts",
category: category,
year: year,
group_type: group_type,
group_id: group_id
)
parsed_response_body = JSON.parse(response.body).symbolize!
parsed_response_body.map! { |c| SBF::Client::Contact.new(c) } if ok?(response)
handle_parsed_response(parsed_response_body, response)
end
|
#groups(category, year) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/stbaldricks/endpoints/communicate.rb', line 20
def groups(category, year)
response = SBF::Client::Api::Request.post_request("#{base_uri}/groups", category: category, year: year)
parsed_response_body = JSON.parse(response.body).symbolize!
handle_parsed_response(parsed_response_body, response)
end
|
#years(category) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/stbaldricks/endpoints/communicate.rb', line 13
def years(category)
response = SBF::Client::Api::Request.post_request("#{base_uri}/years", category: category)
parsed_response_body = JSON.parse(response.body).symbolize!
handle_parsed_response(parsed_response_body, response)
end
|