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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -3
- data/lib/digitalhumani/version.rb +1 -1
- data/lib/digitalhumani.rb +16 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa913d1ec2ab1c45ed2dd145f56ef6aaf74e4e9dcfb5b5a4355be39add1d95f9
|
4
|
+
data.tar.gz: 37774e85afdc0ab6224bea5723fe10135cb07460a5eb3b89a1ce2c620aa54e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a63fa90d17ddcf03b720d6b9fd33f0da63cbd9755ad22a8b536f0cc20e92ed929e58ee3db4913ae11ebcb4bdf015ce7874389427b3ee5af206865c16c1f57c7
|
7
|
+
data.tar.gz: 0c012e7e24d4d4635e189a07e85fb9f92824bd85a818dcca56c69372f0dba05d2d9984818d1d9c6179783e686c0e43aa4cbd13393e4c615e71d574ac8530f8e8
|
data/Gemfile.lock
CHANGED
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
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2021-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|