class AddressService::Address
Public Class Methods
create(resource_type, params)
click to toggle source
Create an address for a given resource type
# File lib/address-service/address.rb, line 33 def create(resource_type, params) path = "/resources/#{resource_type}/" response = client.post path, params case response.status when 201 # TODO: validate that response body is correct format. return response.body when 422 raise Errors::InputError, response.body else raise Errors::UnknownError end end
destroy(resource_type, resource_idu)
click to toggle source
Create an address for a given resource type
# File lib/address-service/address.rb, line 68 def destroy(resource_type, resource_idu) path = "/resources/#{resource_type}/" response = client.delete path case response.status when 200 # TODO: validate that response body is correct format. return response.body when 404 raise Errors::ResourceNotFound else raise Errors::UnknownError end end
find(resource_type, resource_id)
click to toggle source
Find address for resource
# File lib/address-service/address.rb, line 17 def find(resource_type, resource_id) path = "/resources/#{resource_type}/#{resource_id}" response = client.get path case response.status when 200 # TODO: validate that response body is correct format. return response.body when 404 raise Errors::ResourceNotFound else raise Errors::UnknownError end end
list(resource_type)
click to toggle source
List addresses for a given resource type
# File lib/address-service/address.rb, line 9 def list(resource_type) path = "/resources/#{resource_type}/" response = client.get path response.body end
update(resource_type, resource_id, params)
click to toggle source
Update an address
# File lib/address-service/address.rb, line 50 def update(resource_type, resource_id, params) path = "/resources/#{resource_type}/#{resource_id}" response = client.patch path, params case response.status when 200 # TODO: validate that response body is correct format. return response.body when 404 raise Errors::ResourceNotFound when 422 raise Errors::InputError, response.body else raise Errors::UnknownError end end
Private Class Methods
client()
click to toggle source
# File lib/address-service/address.rb, line 85 def client AddressService.client end