Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active July 11, 2018 17:34
Show Gist options
  • Save chelseatroy/fc84c6977357ea6b29c31016e50f9fda to your computer and use it in GitHub Desktop.
Save chelseatroy/fc84c6977357ea6b29c31016e50f9fda to your computer and use it in GitHub Desktop.
Combining Protocol Conventions - Request
require 'uri'
require 'net/http'
class MemberService
def get_members(filters=Hash.new)
query_params = filters.to_query
uri = URI("https://bertrandshealthinsurance.com/members?#{query_params}")
request = Net::HTTP::Get.new(uri.path, {'Content-Type' => 'application/json'})
request.body = json_options: {
only: [:name, :date_of_birth],
include: {
dependents: {
only: [:name, :date_of_birth]
}
}
}.to_json
response = http.request(request)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment