helio-ruby 0.1.0 → 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.
- checksums.yaml +5 -5
- data/Gemfile +1 -1
- data/README.md +15 -11
- data/VERSION +1 -1
- data/helio-ruby.gemspec +2 -2
- data/lib/helio-ruby.rb +2 -0
- data/lib/helio/api_operations/create.rb +2 -0
- data/lib/helio/api_operations/delete.rb +2 -0
- data/lib/helio/api_operations/list.rb +2 -6
- data/lib/helio/api_operations/nested_resource.rb +2 -0
- data/lib/helio/api_operations/request.rb +3 -1
- data/lib/helio/api_operations/save.rb +10 -2
- data/lib/helio/api_resource.rb +3 -1
- data/lib/helio/customer_list.rb +8 -6
- data/lib/helio/errors.rb +2 -0
- data/lib/helio/helio_client.rb +2 -0
- data/lib/helio/helio_object.rb +3 -1
- data/lib/helio/helio_response.rb +2 -0
- data/lib/helio/list_object.rb +3 -1
- data/lib/helio/participant.rb +5 -2
- data/lib/helio/singleton_api_resource.rb +2 -0
- data/lib/helio/util.rb +6 -4
- data/lib/helio/version.rb +3 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: feb36836fb769782a32af06f1192ad06e67e8336fb3443005be71ffe1e86b9d4
|
4
|
+
data.tar.gz: f4121231cf11d6f55368cd94337957b6a7a476d060529241785ee25d22c545a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a200278d2f216a134db5db42f141159311812864983926e313f41dad191828df47d28d965f04866101dc30b832ee74bb05a38117827001a1a670c10298412b48
|
7
|
+
data.tar.gz: 414f534fe747254ff6b845591af4c64abb1a8a7fd06a4c32af5ecbebe3c58d2d8371434ca66bd7365c01ba5fd122bfdf646993534a3c56bbc49d2d828f985555
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
# Helio Ruby Library
|
2
2
|
|
3
|
+
### THIS GEM IS NOT PRODUCTION READY
|
4
|
+
The first production release will be version 1.0.0. Until then, consider this gem unstable as the Helio API is in flux.
|
5
|
+
|
3
6
|
## Installation
|
4
7
|
|
5
8
|
You don't need this source code unless you want to modify the gem. If you just
|
6
9
|
want to use the package, just run:
|
7
10
|
|
8
|
-
gem install helio
|
11
|
+
gem install helio-ruby
|
9
12
|
|
10
13
|
If you want to build the gem from source:
|
11
14
|
|
12
|
-
gem build helio.gemspec
|
15
|
+
gem build helio-ruby.gemspec
|
13
16
|
|
14
17
|
### Requirements
|
15
18
|
|
@@ -25,7 +28,7 @@ compromised in transit and alter the code of gems fetched securely over https:
|
|
25
28
|
source 'https://rubygems.org'
|
26
29
|
|
27
30
|
gem 'rails'
|
28
|
-
gem 'helio'
|
31
|
+
gem 'helio-ruby'
|
29
32
|
```
|
30
33
|
|
31
34
|
## Usage
|
@@ -36,12 +39,13 @@ value:
|
|
36
39
|
|
37
40
|
``` ruby
|
38
41
|
require "helio"
|
42
|
+
Helio.api_id = "..."
|
39
43
|
Helio.api_token = "..."
|
40
44
|
|
41
|
-
# list
|
45
|
+
# list participants
|
42
46
|
Helio::Participant.list()
|
43
47
|
|
44
|
-
# retrieve single
|
48
|
+
# retrieve single participant
|
45
49
|
Helio::Participant.retrieve(
|
46
50
|
"id",
|
47
51
|
)
|
@@ -56,14 +60,14 @@ require "helio"
|
|
56
60
|
|
57
61
|
Helio::Participant.list(
|
58
62
|
{},
|
59
|
-
:api_token => "
|
60
|
-
:api_id => "
|
63
|
+
:api_token => "...",
|
64
|
+
:api_id => "..."
|
61
65
|
)
|
62
66
|
|
63
67
|
Helio::Participant.retrieve(
|
64
68
|
"id",
|
65
|
-
:api_token => "
|
66
|
-
:api_id => "
|
69
|
+
:api_token => "...",
|
70
|
+
:api_id => "..."
|
67
71
|
)
|
68
72
|
```
|
69
73
|
|
@@ -76,8 +80,8 @@ library use any client supported by [Faraday][faraday] by initializing a
|
|
76
80
|
``` ruby
|
77
81
|
conn = Faraday.new
|
78
82
|
client = Helio::HelioClient.new(conn)
|
79
|
-
|
80
|
-
Helio::
|
83
|
+
participant, resp = client.request do
|
84
|
+
Helio::Participant.retrieve(
|
81
85
|
"id",
|
82
86
|
)
|
83
87
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/helio-ruby.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Helio::VERSION
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
9
9
|
s.summary = 'Ruby bindings for the Helio API'
|
10
|
-
s.description = 'Discover design insights with surveys and tests. See https://
|
10
|
+
s.description = 'Discover design insights with surveys and tests. See https://helio.app for details.'
|
11
11
|
s.author = 'Helio'
|
12
|
-
s.email = 'helio
|
12
|
+
s.email = 'help@helio.app'
|
13
13
|
s.homepage = 'https://github.com/zurb/helio-ruby'
|
14
14
|
s.license = 'MIT'
|
15
15
|
|
data/lib/helio-ruby.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
module APIOperations
|
3
5
|
module List
|
@@ -17,12 +19,6 @@ module Helio
|
|
17
19
|
|
18
20
|
obj
|
19
21
|
end
|
20
|
-
|
21
|
-
# The original version of #list was given the somewhat unfortunate name of
|
22
|
-
# #all, and this alias allows us to maintain backward compatibility (the
|
23
|
-
# choice was somewhat misleading in the way that it only returned a single
|
24
|
-
# page rather than all objects).
|
25
|
-
alias all list
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
module APIOperations
|
3
5
|
module Request
|
@@ -44,7 +46,7 @@ module Helio
|
|
44
46
|
base.extend(ClassMethods)
|
45
47
|
end
|
46
48
|
|
47
|
-
|
49
|
+
protected
|
48
50
|
|
49
51
|
def request(method, url, params = {}, opts = {})
|
50
52
|
opts = @opts.merge(Util.normalize_opts(opts))
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
module APIOperations
|
3
5
|
module Save
|
@@ -53,11 +55,17 @@ module Helio
|
|
53
55
|
|
54
56
|
values = serialize_params(self).merge(params)
|
55
57
|
|
58
|
+
request_method = if self['id']
|
59
|
+
:put
|
60
|
+
else
|
61
|
+
:post
|
62
|
+
end
|
63
|
+
|
56
64
|
# note that id gets removed here our call to #url above has already
|
57
65
|
# generated a uri for this object with an identifier baked in
|
58
66
|
values.delete(:id)
|
59
67
|
|
60
|
-
resp, opts = request(
|
68
|
+
resp, opts = request(request_method, save_url, values, opts)
|
61
69
|
initialize_from(resp.data, opts)
|
62
70
|
end
|
63
71
|
|
@@ -65,7 +73,7 @@ module Helio
|
|
65
73
|
base.extend(ClassMethods)
|
66
74
|
end
|
67
75
|
|
68
|
-
|
76
|
+
private
|
69
77
|
|
70
78
|
def save_url
|
71
79
|
# This switch essentially allows us "upsert"-like functionality. If the
|
data/lib/helio/api_resource.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
class APIResource < HelioObject
|
3
5
|
include Helio::APIOperations::Request
|
@@ -49,7 +51,7 @@ module Helio
|
|
49
51
|
unless (id = self["id"])
|
50
52
|
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", "id")
|
51
53
|
end
|
52
|
-
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
54
|
+
"#{self.class.resource_url}/#{CGI.escape(id.to_s)}"
|
53
55
|
end
|
54
56
|
|
55
57
|
def refresh
|
data/lib/helio/customer_list.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
class CustomerList < APIResource
|
3
5
|
extend Helio::APIOperations::Create
|
@@ -6,20 +8,20 @@ module Helio
|
|
6
8
|
extend Helio::APIOperations::List
|
7
9
|
extend Helio::APIOperations::NestedResource
|
8
10
|
|
9
|
-
OBJECT_NAME = "customer_list"
|
11
|
+
OBJECT_NAME = "customer_list"
|
10
12
|
|
11
13
|
save_nested_resource :participant
|
12
14
|
nested_resource_class_methods :participant,
|
13
15
|
operations: %i[create retrieve update delete list]
|
14
16
|
|
15
|
-
# class << self
|
16
|
-
# alias detach_source delete_source
|
17
|
-
# end
|
18
|
-
|
19
17
|
def add_participant(params, opts = {})
|
20
18
|
opts = @opts.merge(Util.normalize_opts(opts))
|
21
|
-
Participant.create(params.merge(
|
19
|
+
Participant.create(params.merge(customer_list_id: id), opts)
|
22
20
|
end
|
23
21
|
|
22
|
+
def participants(params = {}, opts = {})
|
23
|
+
resp, opts = request(:get, resource_url + "/participants", params, Util.normalize_opts(opts))
|
24
|
+
Util.convert_to_helio_object(resp.data, opts)
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/helio/errors.rb
CHANGED
data/lib/helio/helio_client.rb
CHANGED
data/lib/helio/helio_object.rb
CHANGED
data/lib/helio/helio_response.rb
CHANGED
data/lib/helio/list_object.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
class ListObject < HelioObject
|
3
5
|
include Enumerable
|
@@ -5,7 +7,7 @@ module Helio
|
|
5
7
|
include Helio::APIOperations::Request
|
6
8
|
include Helio::APIOperations::Create
|
7
9
|
|
8
|
-
OBJECT_NAME = "list"
|
10
|
+
OBJECT_NAME = "list"
|
9
11
|
|
10
12
|
# This accessor allows a `ListObject` to inherit various filters that were
|
11
13
|
# given to a predecessor. This allows for things like consistent limits,
|
data/lib/helio/participant.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Helio
|
2
4
|
class Participant < APIResource
|
3
|
-
|
5
|
+
extend Helio::APIOperations::Create
|
4
6
|
include Helio::APIOperations::Delete
|
7
|
+
include Helio::APIOperations::Save
|
5
8
|
extend Helio::APIOperations::List
|
6
9
|
|
7
|
-
OBJECT_NAME = "participant"
|
10
|
+
OBJECT_NAME = "participant"
|
8
11
|
end
|
9
12
|
end
|
data/lib/helio/util.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "cgi"
|
2
4
|
|
3
5
|
module Helio
|
@@ -8,19 +10,19 @@ module Helio
|
|
8
10
|
:api_token,
|
9
11
|
:idempotency_key,
|
10
12
|
:helio_version
|
11
|
-
]
|
13
|
+
]
|
12
14
|
|
13
15
|
# Options that should be copyable from one HelioObject to another
|
14
16
|
# including options that may be internal.
|
15
17
|
OPTS_COPYABLE = (
|
16
18
|
OPTS_USER_SPECIFIED + Set[:api_base]
|
17
|
-
)
|
19
|
+
)
|
18
20
|
|
19
21
|
# Options that should be persisted between API requests. This includes
|
20
22
|
# client, which is an object containing an HTTP client to reuse.
|
21
23
|
OPTS_PERSISTABLE = (
|
22
24
|
OPTS_USER_SPECIFIED + Set[:client] - Set[:idempotency_key]
|
23
|
-
)
|
25
|
+
)
|
24
26
|
|
25
27
|
def self.objects_to_ids(h)
|
26
28
|
case h
|
@@ -66,7 +68,7 @@ module Helio
|
|
66
68
|
data.map { |i| convert_to_helio_object(i, opts) }
|
67
69
|
when Hash
|
68
70
|
# Try converting to a known object class. If none available, fall back to generic HelioObject
|
69
|
-
object_classes.fetch(data[:
|
71
|
+
object_classes.fetch(data[:object_type], HelioObject).construct_from(data, opts)
|
70
72
|
else
|
71
73
|
data
|
72
74
|
end
|
data/lib/helio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helio-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Helio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,9 +24,9 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.10'
|
27
|
-
description: Discover design insights with surveys and tests. See https://
|
27
|
+
description: Discover design insights with surveys and tests. See https://helio.app
|
28
28
|
for details.
|
29
|
-
email: helio
|
29
|
+
email: help@helio.app
|
30
30
|
executables:
|
31
31
|
- helio-console
|
32
32
|
extensions: []
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.6
|
87
|
+
rubygems_version: 2.7.6
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Ruby bindings for the Helio API
|