digitalhumani 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14a663d43b2ef4aa923f1731936a8e8da8919412519b35b777f2c9dc102e6360
4
- data.tar.gz: 13c0e230523558df5a48ce8023fcafb762914775f0fe98f0885b9903ea76f6af
3
+ metadata.gz: fa913d1ec2ab1c45ed2dd145f56ef6aaf74e4e9dcfb5b5a4355be39add1d95f9
4
+ data.tar.gz: 37774e85afdc0ab6224bea5723fe10135cb07460a5eb3b89a1ce2c620aa54e59
5
5
  SHA512:
6
- metadata.gz: 9c2aa52feacbbf7232f08325ef9aa791ef864f6a765182d80eda340e28b15e4d776fdb22d234056f5021cbd5c4c482c38a1b760c12fc959fd5312a3b6aa05659
7
- data.tar.gz: 73fcc12cd9faf8ad561b4f2487a9c66942a401369be1026b3c557590fb75bc9b6cfa0761960f7b83402ef8f2a862bf05c9f8542f8217b6acc2ef010e012ec6ff
6
+ metadata.gz: 5a63fa90d17ddcf03b720d6b9fd33f0da63cbd9755ad22a8b536f0cc20e92ed929e58ee3db4913ae11ebcb4bdf015ce7874389427b3ee5af206865c16c1f57c7
7
+ data.tar.gz: 0c012e7e24d4d4635e189a07e85fb9f92824bd85a818dcca56c69372f0dba05d2d9984818d1d9c6179783e686c0e43aa4cbd13393e4c615e71d574ac8530f8e8
data/Gemfile.lock CHANGED
@@ -35,7 +35,7 @@ GEM
35
35
  multipart-post (2.1.1)
36
36
  public_suffix (4.0.6)
37
37
  rake (13.0.6)
38
- rexml (3.2.4)
38
+ rexml (3.2.5)
39
39
  rspec (3.10.0)
40
40
  rspec-core (~> 3.10.0)
41
41
  rspec-expectations (~> 3.10.0)
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # DigitalHumani Ruby SDK
2
2
 
3
- | :warning: | This gem is currently under development and not yet published nor recommended for production use |
4
- | --------- | :----------------------------------------------------------------------------------------------- |
5
-
6
3
  This repository hosts the DigitalHumani Ruby Gem SDK. It can be used for interacting with the DigitalHumani RaaS (Reforestation-as-a-Service) API.
7
4
 
8
5
  ## Installation
@@ -24,6 +21,7 @@ Or install it yourself as:
24
21
  ## Preparation
25
22
 
26
23
  - Create an account on [DigitalHumani,com](https://my.digitalhumani.com/register) and grab your API key from the **Developer** menu item.
24
+ - Note that you'll use a different API key per environment (production vs sandbox)
27
25
  - Review the [DigitalHumani documentation](https://docs.digitalhumani.com) to familiarize yourself with the environments, requests, projects, etc
28
26
 
29
27
  ## Usage
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DigitalHumani
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/digitalhumani.rb CHANGED
@@ -19,7 +19,7 @@ module DigitalHumani
19
19
  if !@api_key or @api_key === ""
20
20
  raise "Error: @api_key parameter required"
21
21
  end
22
- if !@environment or !["production","sandbox"].include?(@environment)
22
+ if !@environment or !["production","sandbox","local"].include?(@environment)
23
23
  raise "Error: @environment parameter required and must be one of 'production','sandbox'"
24
24
  end
25
25
 
@@ -29,6 +29,8 @@ module DigitalHumani
29
29
  @url = "https://api.digitalhumani.com/"
30
30
  when "sandbox"
31
31
  @url = "https://api.sandbox.digitalhumani.com"
32
+ when "local"
33
+ @url = "http://localhost:3000"
32
34
  end
33
35
  end
34
36
 
@@ -126,7 +128,19 @@ module DigitalHumani
126
128
  def request(http_method:, endpoint:, params: {})
127
129
  params = JSON.generate(params) if !params.empty? and http_method != :get
128
130
  response = client.public_send(http_method, endpoint, params)
129
- JSON.parse(response.body)
131
+
132
+ if response.status === 200
133
+ return JSON.parse(response.body)
134
+ elsif response.status === 401 or response.status === 403
135
+ raise response.status.to_s + " " + response.body
136
+ else
137
+ if response.headers.include?("content-type") and response.headers["content-type"].start_with?("application/json")
138
+ json = JSON.parse(response.body)
139
+ raise response.status.to_s + " | " + json['message']
140
+ else
141
+ raise response.status.to_s + " | " + response.body
142
+ end
143
+ end
130
144
  end
131
145
 
132
146
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digitalhumani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Scheller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2021-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday