alloy-api 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +1 -0
  4. data/lib/alloy-api.rb +2 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 642721aa9c89391716cea4f0d4ae4a86938b4106de8a02811223ebc3aa373050
4
- data.tar.gz: b983d1b9c6a1810e2fa27d4f27a8da3b30e3587615985cc0156eb17be3dca4cf
3
+ metadata.gz: f1076ec91022b7cb844f4cc76e0b04dad0443264a3251664fc475f14c0d94084
4
+ data.tar.gz: a91bf5c6064ffc4efc064847a5177167a38f0e7dfc1b46f6985c444e0aeede1b
5
5
  SHA512:
6
- metadata.gz: cd88a8990194bd30bd75af695c189422bc0728b7114b368fbae6d0f0a3e3be2a80810b9e8a76e958007f94cfa362f7395c472ef21a2300bd8bd8a1f252c7e06a
7
- data.tar.gz: 0f210ddce06c592cc5df6a7e93d3eeed891f7ee69b63d835f9ad590f99fa2912817d160b1239ad32f7ae56414bef68ddd9036a409c9f99f3c491612290712e70
6
+ metadata.gz: 19b6fecf31ea23cfd1e6ef6afeed2c43a5def2cdd116fe531e965fff72eda1d10fd6b133ae3238f5dc066a30d5bf7ebc554764270e48c4e5075a76c8ad6cef72
7
+ data.tar.gz: 58672b36421dc156ff4c0c486bd48c3d3e8b3a9e330f2283c1e1b5d21135813325facfa4b72ddc7d65faee94fe5fd442db47d6a50f9efa82781289b29e703f00
@@ -1,3 +1,7 @@
1
+ ## 0.0.7 / 2020-06-29
2
+
3
+ * Support non-JSON body encoding
4
+
1
5
  ## 0.0.6 / 2020-06-18
2
6
 
3
7
  * Allow body stream
data/README.md CHANGED
@@ -53,6 +53,7 @@ The Alloy.co api methods are implemented by the Api class. Most take a set of op
53
53
  Alloy::Api.parameters(method: 'get') # The default method is 'post' - this method will get required/optional parameters for running evaluations
54
54
  Alloy::Api.evaluations(body: { first_name: 'John', last_name: 'Smith' }, headers: { 'Alloy-Refresh-Cache': 'true' }) # Runs an evaluation. Headers can be set as well, but the Content-Type and Authorization are automatic
55
55
  Alloy::Api.parameters(method: 'get', endpoint: :other_endpoint) # use a different endpoint - allowing for multiple workflows to be used
56
+ Alloy::Api.some_method(body: "hello world", body_encoding: :to_s) # use to_s on the body object instead of to_json. Important for non-json uploads
56
57
  ```
57
58
 
58
59
  ## License
@@ -46,6 +46,7 @@ module Alloy
46
46
  method = options[:method] || "post"
47
47
  endpoint = options[:endpoint] || :main
48
48
  uri = "#{@@api_endpoints[endpoint][:uri]}#{path}"
49
+ body_encoding = options[:body_encoding] || :to_json
49
50
  headers = {
50
51
  "Content-Type" => "application/json",
51
52
  "Authorization" => auth_param(endpoint)
@@ -53,7 +54,7 @@ module Alloy
53
54
  if options[:body_stream].present?
54
55
  response = HTTParty.send(method, uri, { headers: headers, body_stream: options[:body_stream] })
55
56
  else
56
- response = HTTParty.send(method, uri, {headers: headers, body: (options[:body] || {}).to_json})
57
+ response = HTTParty.send(method, uri, { headers: headers, body: (options[:body] || {}).send(body_encoding) })
57
58
  end
58
59
  return response if options[:raw]
59
60
  JSON.parse(response.body)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alloy-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Schultz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty