Skip to content

Commit

Permalink
Merge pull request #3 from mlibrary/post-with-body
Browse files Browse the repository at this point in the history
added back content-type to headers
  • Loading branch information
niquerio authored Jul 19, 2021
2 parents 01122b9 + 99f7bf6 commit 39968fe
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
alma_rest_client (0.2.1)
alma_rest_client (1.0.1)
httparty
ox

Expand Down
1 change: 1 addition & 0 deletions lib/alma_rest_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Client
def initialize()
self.class.headers 'Authorization' => "apikey #{ENV.fetch('ALMA_API_KEY')}"
self.class.headers 'Accept' => 'application/json'
self.class.headers 'Content-Type' => 'application/json'
end

[:get, :post, :delete, :put].each do |name|
Expand Down
2 changes: 1 addition & 1 deletion lib/alma_rest_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module AlmaRestClient
VERSION = "1.0.0"
VERSION = "1.0.1"
end
2 changes: 1 addition & 1 deletion spec/alma_rest_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
end
it "handles query and body" do
stub_alma_post_request(url: 'users/soandso/loans', query: {"op" => "hold"}, input: {thing: 'stuff'})
expect(subject.post('/users/soandso/loans', query: {"op" => "hold"}, body: {thing: 'stuff'}).class.name).to eq("HTTParty::Response")
expect(subject.post('/users/soandso/loans', query: {"op" => "hold"}, body: {thing: 'stuff'}.to_json).class.name).to eq("HTTParty::Response")
end
end
context "#delete(url, query: {})" do
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
accept: 'application/json',
Authorization: "apikey #{ENV['ALMA_API_KEY']}",
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'User-Agent'=>'Ruby'
'User-Agent'=>'Ruby',
'Content-Type' => 'application/json'
}
req_attributes[:body] = input unless input.nil?
req_attributes[:query] = query unless query.nil?
Expand Down

0 comments on commit 39968fe

Please sign in to comment.