class SBF::Client::CommunicateEndpoint
Public Instance Methods
categories(_ = nil)
click to toggle source
# 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 = {})
click to toggle source
# 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
contacts(category, year, group_type, group_id)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
handle_parsed_response(data, response)
click to toggle source
# File lib/stbaldricks/endpoints/communicate.rb, line 56 def handle_parsed_response(data, response) unless ok?(response) error = SBF::Client::ErrorEntity.new(data) data = nil end SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error) end