pnut 0.1.2 → 0.2.0

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pnut.rb +8 -3
  3. data/lib/pnut/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b2a3a8f1260f96e01bdf32d7df84081c7947db3e3f4bc8c38de75e88c6b0ceb
4
- data.tar.gz: 4d46cce57a1453efb6ed7ac760c15e1f461c2de5e0b78fcd4a14e91ae5173379
3
+ metadata.gz: eeeda2c2c3813e67bd8446308e0688fc7949fa15c2fabe79f36b37f96a7f9c93
4
+ data.tar.gz: 2e5372cdd14dde4c2282993558e4e3c7aad38ed4d71e49ebf0a3190e2c1a3872
5
5
  SHA512:
6
- metadata.gz: 253def5b328479e324be828a6f5789541a6974146f023d3a01528b3d9c83f9726df40690c22bdaafdeb17f8f133438bf0ff7610f5777fa90c532440c53db9526
7
- data.tar.gz: 87a5eefdbfad35a00a9ad0cfe5f66bae5f43a44414b8549fb6c561d3a30890da31b615110efd292747e359c7d017d29c7c5ba1d679947c1e4b37e8079f17593d
6
+ metadata.gz: 4c985932c944530094910d7b143b49bbad0afe29c989ba36c66d53ea15baf7d9ddd692d761ad837c948111b561634f738e292f21dd9593497d52af32083bcee5
7
+ data.tar.gz: 94472f946a9caaae19758e332e0308227a28be77b42194f940c4c11081410f4fc85dd7ca53d500c032abcd0e7c307fcfbf21b579b4b1999b7678596a695190d5
@@ -14,7 +14,7 @@ module Pnut
14
14
  @connection = Faraday.new("https://api.pnut.io/")
15
15
  end
16
16
 
17
- def request(endpoint, method: "GET", params: nil, data: nil, raw_response: false)
17
+ def request(endpoint, method: "GET", params: nil, data: nil, raw_response: false, json: true)
18
18
  prepared_endpoint = "/v0#{endpoint}"
19
19
 
20
20
  if params
@@ -25,10 +25,15 @@ module Pnut
25
25
 
26
26
  response = @connection.send(method.downcase.to_sym, prepared_endpoint) do |req|
27
27
  req.url prepared_endpoint
28
- req.headers["Content-Type"] = "application/json"
29
28
 
29
+ req.headers["Content-Type"] = "application/json" if json
30
30
  req.headers["Authorization"] = "Bearer #{@token}" if @token
31
- req.body = data.to_json if data
31
+
32
+ if json
33
+ req.body = data.to_json if data
34
+ else
35
+ req.body = data if data
36
+ end
32
37
  end
33
38
 
34
39
  raw_response ? response.body : JSON.parse(response.body, object_class: OpenStruct)
@@ -1,3 +1,3 @@
1
1
  module Pnut
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pnut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Wood
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-14 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday