customerio 5.6.0 → 6.1.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 +4 -4
- data/README.md +144 -12
- data/lib/customerio/api.rb +47 -57
- data/lib/customerio/base_client.rb +26 -20
- data/lib/customerio/client.rb +153 -75
- data/lib/customerio/regions.rb +3 -4
- data/lib/customerio/requests/send_email_request.rb +22 -23
- data/lib/customerio/requests/send_in_app_request.rb +12 -16
- data/lib/customerio/requests/send_inbox_message_request.rb +12 -16
- data/lib/customerio/requests/send_push_request.rb +16 -15
- data/lib/customerio/requests/send_sms_request.rb +21 -23
- data/lib/customerio/requests/trigger_broadcast_request.rb +28 -0
- data/lib/customerio/version.rb +3 -1
- data/lib/customerio.rb +3 -1
- metadata +17 -99
- data/.github/workflows/main.yml +0 -21
- data/.gitignore +0 -20
- data/.gitpod.yml +0 -10
- data/CHANGELOG.markdown +0 -185
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/customerio.gemspec +0 -27
- data/lib/customerio/param_encoder.rb +0 -68
- data/spec/api_client_spec.rb +0 -432
- data/spec/base_client_spec.rb +0 -67
- data/spec/client_spec.rb +0 -718
- data/spec/spec_helper.rb +0 -15
data/lib/customerio.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "customerio/version"
|
|
2
4
|
|
|
3
5
|
module Customerio
|
|
@@ -9,6 +11,6 @@ module Customerio
|
|
|
9
11
|
require "customerio/requests/send_sms_request"
|
|
10
12
|
require "customerio/requests/send_inbox_message_request"
|
|
11
13
|
require "customerio/requests/send_in_app_request"
|
|
14
|
+
require "customerio/requests/trigger_broadcast_request"
|
|
12
15
|
require "customerio/api"
|
|
13
|
-
require "customerio/param_encoder"
|
|
14
16
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: customerio
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Allison
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: multi_json
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.0'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.0'
|
|
27
12
|
- !ruby/object:Gem::Dependency
|
|
28
13
|
name: addressable
|
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,107 +29,45 @@ dependencies:
|
|
|
44
29
|
requirements:
|
|
45
30
|
- - "~>"
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.3
|
|
32
|
+
version: '0.3'
|
|
48
33
|
type: :runtime
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
37
|
- - "~>"
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.3
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '10.5'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '10.5'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rspec
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '3.10'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '3.10'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: webmock
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - '='
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: 3.6.0
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - '='
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: 3.6.0
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: json
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - ">="
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - ">="
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
111
|
-
description: A ruby client for the Customer.io event API.
|
|
39
|
+
version: '0.3'
|
|
40
|
+
description: A ruby client for the Customer.io Journeys Track API and Transactional
|
|
41
|
+
API.
|
|
112
42
|
email:
|
|
113
43
|
- john@customer.io
|
|
114
44
|
executables: []
|
|
115
45
|
extensions: []
|
|
116
46
|
extra_rdoc_files: []
|
|
117
47
|
files:
|
|
118
|
-
- ".github/workflows/main.yml"
|
|
119
|
-
- ".gitignore"
|
|
120
|
-
- ".gitpod.yml"
|
|
121
|
-
- CHANGELOG.markdown
|
|
122
|
-
- Gemfile
|
|
123
48
|
- LICENSE
|
|
124
49
|
- README.md
|
|
125
|
-
- Rakefile
|
|
126
|
-
- customerio.gemspec
|
|
127
50
|
- lib/customerio.rb
|
|
128
51
|
- lib/customerio/api.rb
|
|
129
52
|
- lib/customerio/base_client.rb
|
|
130
53
|
- lib/customerio/client.rb
|
|
131
|
-
- lib/customerio/param_encoder.rb
|
|
132
54
|
- lib/customerio/regions.rb
|
|
133
55
|
- lib/customerio/requests/send_email_request.rb
|
|
134
56
|
- lib/customerio/requests/send_in_app_request.rb
|
|
135
57
|
- lib/customerio/requests/send_inbox_message_request.rb
|
|
136
58
|
- lib/customerio/requests/send_push_request.rb
|
|
137
59
|
- lib/customerio/requests/send_sms_request.rb
|
|
60
|
+
- lib/customerio/requests/trigger_broadcast_request.rb
|
|
138
61
|
- lib/customerio/version.rb
|
|
139
|
-
- spec/api_client_spec.rb
|
|
140
|
-
- spec/base_client_spec.rb
|
|
141
|
-
- spec/client_spec.rb
|
|
142
|
-
- spec/spec_helper.rb
|
|
143
62
|
homepage: https://customer.io
|
|
144
63
|
licenses:
|
|
145
64
|
- MIT
|
|
146
|
-
metadata:
|
|
147
|
-
|
|
65
|
+
metadata:
|
|
66
|
+
bug_tracker_uri: https://github.com/customerio/customerio-ruby/issues
|
|
67
|
+
changelog_uri: https://github.com/customerio/customerio-ruby/releases
|
|
68
|
+
homepage_uri: https://customer.io
|
|
69
|
+
rubygems_mfa_required: 'true'
|
|
70
|
+
source_code_uri: https://github.com/customerio/customerio-ruby
|
|
148
71
|
rdoc_options: []
|
|
149
72
|
require_paths:
|
|
150
73
|
- lib
|
|
@@ -152,19 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
152
75
|
requirements:
|
|
153
76
|
- - ">="
|
|
154
77
|
- !ruby/object:Gem::Version
|
|
155
|
-
version: '
|
|
78
|
+
version: '3.3'
|
|
156
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
80
|
requirements:
|
|
158
81
|
- - ">="
|
|
159
82
|
- !ruby/object:Gem::Version
|
|
160
83
|
version: '0'
|
|
161
84
|
requirements: []
|
|
162
|
-
rubygems_version: 3.
|
|
163
|
-
signing_key:
|
|
85
|
+
rubygems_version: 3.6.9
|
|
164
86
|
specification_version: 4
|
|
165
|
-
summary: A ruby client for the Customer.io
|
|
166
|
-
test_files:
|
|
167
|
-
- spec/api_client_spec.rb
|
|
168
|
-
- spec/base_client_spec.rb
|
|
169
|
-
- spec/client_spec.rb
|
|
170
|
-
- spec/spec_helper.rb
|
|
87
|
+
summary: A ruby client for the Customer.io Journeys Track API and Transactional API.
|
|
88
|
+
test_files: []
|
data/.github/workflows/main.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: ci
|
|
2
|
-
|
|
3
|
-
on: [push,pull_request]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
test:
|
|
7
|
-
strategy:
|
|
8
|
-
matrix:
|
|
9
|
-
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
env:
|
|
12
|
-
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1.229.0
|
|
16
|
-
with:
|
|
17
|
-
ruby-version: ${{ matrix.ruby }}
|
|
18
|
-
bundler-cache: true
|
|
19
|
-
|
|
20
|
-
- name: Unit Test w/ RSpec
|
|
21
|
-
run: bundle exec rspec
|
data/.gitignore
DELETED
data/.gitpod.yml
DELETED
data/CHANGELOG.markdown
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
## Customerio 5.4.0 - June 13, 2025
|
|
2
|
-
### Changed
|
|
3
|
-
- Added `send_sms` to `APIClient` and `SendSMSRequest` to support sending transactional push notifications.
|
|
4
|
-
|
|
5
|
-
## Customerio 5.3.0 - December 8, 2023
|
|
6
|
-
### Changed
|
|
7
|
-
- The `identify` method has been updated to allow the customer ID to be specified separately from the attributes, using the `customer_id` attribute. This allows a person to be updated by identifying them by e.g.: their email address. Thanks to trwalzer, jrbeck and jeremyw for the original changes that this is based on.
|
|
8
|
-
- It is no longer possible to set the `customer_id` attribute on a person. This is a side-effect of the changes to the `identify` method.
|
|
9
|
-
|
|
10
|
-
## Customerio 5.2.0 - December 8, 2023
|
|
11
|
-
### Changed
|
|
12
|
-
- The `identify` method will now automatically use the `cio_id` attribute as the customer ID when calling the track service. This allows a customer to be updated using `identify` to modify the `id` and `email` attributes.
|
|
13
|
-
|
|
14
|
-
## Customerio 5.1.0 - May 5, 2023
|
|
15
|
-
### Added
|
|
16
|
-
- Added `send_push` to `APIClient` and `SendPushRequest` to support sending transactional push notifications.
|
|
17
|
-
|
|
18
|
-
## Customerio 4.3.1 - January 5, 2023
|
|
19
|
-
### Added
|
|
20
|
-
- Added the `disable_css_preprocessing` and `language` optional fields to send request
|
|
21
|
-
|
|
22
|
-
## Customerio 4.3.0 - April 26, 2022
|
|
23
|
-
### Added
|
|
24
|
-
- Support for [anonymous invite events](https://customer.io/docs/anonymous-invite-emails/) by setting `anonymous_id` to `nil`.
|
|
25
|
-
|
|
26
|
-
## Customerio 4.1.0 - Sep 27, 2021
|
|
27
|
-
### Added
|
|
28
|
-
- Added support for [merge customers](https://customer.io/docs/api/#operation/merge) API
|
|
29
|
-
|
|
30
|
-
## Customerio 4.0.1 - July 13, 2021
|
|
31
|
-
### Changed
|
|
32
|
-
- Update addressable gem dependency to v2.8.0
|
|
33
|
-
|
|
34
|
-
## Customerio 4.0.0 - July 6, 2021
|
|
35
|
-
### Removed
|
|
36
|
-
- The `anonymous_track` method.
|
|
37
|
-
|
|
38
|
-
### Added
|
|
39
|
-
- The `track_anonymous` method replaces `anonymous_track`. This method requires an `anonymous_id` parameter and will no longer trigger campaigns. If you previously used anonymous events to trigger campaigns, you can still do so [directly through the API](https://customer.io/docs/api/#operation/trackAnonymous). We now refer to anonymous events that trigger campaigns as ["invite events"](https://customer.io/docs/anonymous-events/#anonymous-or-invite).
|
|
40
|
-
|
|
41
|
-
## Customerio 3.1.0 - March 25, 2021
|
|
42
|
-
### Added
|
|
43
|
-
- Support for EU region
|
|
44
|
-
|
|
45
|
-
### Removed
|
|
46
|
-
### Changed
|
|
47
|
-
- `Customerio::Client` and `CustomerIO::APIClient` have a new parameter `region` that can be set to either `Customerio::Regions::EU` or `Customerio::Regions::US` (defaults to `Customerio::Regions::US`)
|
|
48
|
-
|
|
49
|
-
## Customerio 3.0.0 - Dec 2, 2020
|
|
50
|
-
|
|
51
|
-
### Added
|
|
52
|
-
- Support for the Transactional API
|
|
53
|
-
|
|
54
|
-
### Removed
|
|
55
|
-
- `add_to_segment` and `remove_from_segment` methods
|
|
56
|
-
- Support for non-JSON data
|
|
57
|
-
|
|
58
|
-
### Changed
|
|
59
|
-
- IDs in the URLs are now escaped.
|
|
60
|
-
- Improved validations for data that's passed in.
|
|
61
|
-
- Earlier, if you passed in an event name without a customer ID to the `track` method, we would create an anonymous event. That is now removed. To create an anonymous event, use the `anonymous_track` method.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Customerio 3.0.0 - Dec 2, 2020
|
|
65
|
-
|
|
66
|
-
### Added
|
|
67
|
-
- Support for the Transactional API
|
|
68
|
-
|
|
69
|
-
### Removed
|
|
70
|
-
- `add_to_segment` and `remove_from_segment` methods
|
|
71
|
-
- Support for non-JSON data
|
|
72
|
-
|
|
73
|
-
### Changed
|
|
74
|
-
- IDs in the URLs are now escaped.
|
|
75
|
-
- Improved validations for data that's passed in.
|
|
76
|
-
- Earlier, if you passed in an event name without a customer ID to the `track` method, we would create an anonymous event. That is now removed. To create an anonymous event, use the `anonymous_track` method.
|
|
77
|
-
|
|
78
|
-
## Customerio 2.2.1 - Mar 23, 2020
|
|
79
|
-
|
|
80
|
-
- Add license to gemspec [#55](https://github.com/customerio/customerio-ruby/pull/55)
|
|
81
|
-
- Bubble up error message [#51](https://github.com/customerio/customerio-ruby/pull/51)
|
|
82
|
-
|
|
83
|
-
## Customerio 2.2.0 - Oct 18, 2018
|
|
84
|
-
|
|
85
|
-
Add support for manual segments [#52](https://github.com/customerio/customerio-ruby/pull/52)
|
|
86
|
-
|
|
87
|
-
## Customerio 2.1.0 - May 22, 2018
|
|
88
|
-
|
|
89
|
-
Added support for the suppress / unsuppress methods [#49](https://github.com/customerio/customerio-ruby/pull/49)
|
|
90
|
-
|
|
91
|
-
## Customerio 2.0.0 - Apr 10, 2018
|
|
92
|
-
|
|
93
|
-
With this release we have dropped the support for ruby 1.8.7.
|
|
94
|
-
|
|
95
|
-
- Support new add and remove device endpoints for push notifications [#47](https://github.com/customerio/customerio-ruby/pull/47)
|
|
96
|
-
|
|
97
|
-
## Customerio 1.0.0 - Mar 15, 2016
|
|
98
|
-
|
|
99
|
-
There is a slight breaking change in this release. If you are depending on the HTTP response object included in the InvalidResponse exception (introduced in 0.6.1), note that it is now a `Net::HTTPBadRequest`.
|
|
100
|
-
|
|
101
|
-
- Remove HTTParty dependency, use Net::HTTP instead. [#42](https://github.com/customerio/customerio-ruby/pull/42)
|
|
102
|
-
|
|
103
|
-
- Update test suite to use webmock, to increase confidence that we're not changing our HTTP requests [#41](https://github.com/customerio/customerio-ruby/pull/41)
|
|
104
|
-
|
|
105
|
-
## Customerio 0.7.0 - Mar 2, 2016
|
|
106
|
-
|
|
107
|
-
- Add new method for tracking anonymous events: `anonymous_track`. See README for more details. Many thanks to @sdawson for this contribution! [#36](https://github.com/customerio/customerio-ruby/pull/36)
|
|
108
|
-
|
|
109
|
-
- Use JSON encoding by default. [#37](https://github.com/customerio/customerio-ruby/pull/37)
|
|
110
|
-
|
|
111
|
-
If you want to stick with form-encoding for your integration, you must add `:json => false` to your Customerio::Client initializer. Like this:
|
|
112
|
-
|
|
113
|
-
```ruby
|
|
114
|
-
customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", :json => false)
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Customerio 0.6.1 - Oct 8, 2015
|
|
118
|
-
|
|
119
|
-
- Include HTTP response as an attribute on the InvalidResponse exception to help with debugging failed API requests. For example:
|
|
120
|
-
|
|
121
|
-
```ruby
|
|
122
|
-
begin
|
|
123
|
-
$customerio.track(1, 'event', { :test => 'testing' })
|
|
124
|
-
rescue => e
|
|
125
|
-
puts e.message
|
|
126
|
-
puts e.response.status
|
|
127
|
-
puts e.response.body
|
|
128
|
-
end
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Customerio 0.6.0 - Oct 6, 2015
|
|
132
|
-
|
|
133
|
-
Deprecation warning: we are going to switch to JSON encoding by default for the next release. The current default is form-encoding. This will probably not affect you, unless you rely on how form-encoding arrays work.
|
|
134
|
-
|
|
135
|
-
If you want to stick with form-encoding for your integration, you must add `:json => false` to your Customerio::Client initializer. Like this:
|
|
136
|
-
|
|
137
|
-
```ruby
|
|
138
|
-
customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", :json => false)
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Other fixes and improvements, with many thanks to the community contributors:
|
|
142
|
-
|
|
143
|
-
- Added HTTP timeout of 10 seconds (@stayhero)
|
|
144
|
-
- Added JSON support for events (@kemper)
|
|
145
|
-
- Convert attribute keys to symbols (@joshnabbott)
|
|
146
|
-
|
|
147
|
-
## Customerio 0.5.0 - Mar 28, 2014
|
|
148
|
-
|
|
149
|
-
- Added flag to send body encoded as JSON, rather than the default form encoding.
|
|
150
|
-
|
|
151
|
-
## Customerio 0.5.0 - Apr 8, 2013
|
|
152
|
-
|
|
153
|
-
- Removed deprecated methods around using a customer object. All calls simply take a hash of attributes now.
|
|
154
|
-
- Added ability to set a timestamp on a tracked event. Useful for backfilling past events.
|
|
155
|
-
|
|
156
|
-
## Customerio 0.4.1 - Feb 18, 2013
|
|
157
|
-
|
|
158
|
-
- Bug fixes related to the 4.0 change.
|
|
159
|
-
|
|
160
|
-
## Customerio 0.4.0 - Feb 18, 2013
|
|
161
|
-
|
|
162
|
-
- Added support for deleting customers.
|
|
163
|
-
|
|
164
|
-
## Customerio 0.3.0 - Dec 28, 2012
|
|
165
|
-
|
|
166
|
-
- Now raise an error if an API call doesn't respond with a 200 response code
|
|
167
|
-
- Removed dependency on ActiveSupport
|
|
168
|
-
|
|
169
|
-
## Customerio 0.2.0 - Nov 21, 2012
|
|
170
|
-
|
|
171
|
-
- Allow raw hashes to be passed into `identify` and `track` methods rather than a customer object.
|
|
172
|
-
- Passing a customer object has been depreciated.
|
|
173
|
-
- Customizing ids with `Customerio::Client.id` block is deprecated.
|
|
174
|
-
|
|
175
|
-
## Customerio 0.1.0 - Nov 15, 2012
|
|
176
|
-
|
|
177
|
-
- Allow tracking of anonymous events.
|
|
178
|
-
|
|
179
|
-
## Customerio 0.0.3 - Nov 5, 2012
|
|
180
|
-
|
|
181
|
-
- Bump httparty dependency to the latest version.
|
|
182
|
-
|
|
183
|
-
## Customerio 0.0.2 - May 22, 2012
|
|
184
|
-
|
|
185
|
-
- First release.
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/customerio.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
require File.expand_path('../lib/customerio/version', __FILE__)
|
|
3
|
-
|
|
4
|
-
Gem::Specification.new do |gem|
|
|
5
|
-
gem.authors = ["John Allison"]
|
|
6
|
-
gem.email = ["john@customer.io"]
|
|
7
|
-
gem.description = "A ruby client for the Customer.io event API."
|
|
8
|
-
gem.summary = "A ruby client for the Customer.io event API."
|
|
9
|
-
gem.homepage = "https://customer.io"
|
|
10
|
-
gem.license = "MIT"
|
|
11
|
-
|
|
12
|
-
gem.files = `git ls-files`.split($\)
|
|
13
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
14
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
15
|
-
gem.name = "customerio"
|
|
16
|
-
gem.require_paths = ["lib"]
|
|
17
|
-
gem.version = Customerio::VERSION
|
|
18
|
-
|
|
19
|
-
gem.add_dependency('multi_json', "~> 1.0")
|
|
20
|
-
gem.add_dependency('addressable', '~> 2.9')
|
|
21
|
-
gem.add_dependency('base64', '~> 0.3.0')
|
|
22
|
-
|
|
23
|
-
gem.add_development_dependency('rake', '~> 10.5')
|
|
24
|
-
gem.add_development_dependency('rspec', '~> 3.10')
|
|
25
|
-
gem.add_development_dependency('webmock', '3.6.0')
|
|
26
|
-
gem.add_development_dependency('json')
|
|
27
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Based on HTTParty's HashConversions:
|
|
2
|
-
#
|
|
3
|
-
# https://github.com/jnunemaker/httparty/blob/master/lib/httparty/hash_conversions.rb
|
|
4
|
-
#
|
|
5
|
-
# License: MIT https://github.com/jnunemaker/httparty/blob/master/MIT-LICENSE
|
|
6
|
-
|
|
7
|
-
require 'erb'
|
|
8
|
-
require 'uri'
|
|
9
|
-
|
|
10
|
-
module Customerio
|
|
11
|
-
class ParamEncoder
|
|
12
|
-
# @return <String> This hash as a query string
|
|
13
|
-
#
|
|
14
|
-
# @example
|
|
15
|
-
# { name: "Bob",
|
|
16
|
-
# address: {
|
|
17
|
-
# street: '111 Ruby Ave.',
|
|
18
|
-
# city: 'Ruby Central',
|
|
19
|
-
# phones: ['111-111-1111', '222-222-2222']
|
|
20
|
-
# }
|
|
21
|
-
# }.to_params
|
|
22
|
-
# #=> "name=Bob&address[city]=Ruby Central&address[phones][]=111-111-1111&address[phones][]=222-222-2222&address[street]=111 Ruby Ave."
|
|
23
|
-
def self.to_params(hash)
|
|
24
|
-
hash.to_hash.map { |k, v| normalize_param(k, v) }.join.chop
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# @param key<Object> The key for the param.
|
|
28
|
-
# @param value<Object> The value for the param.
|
|
29
|
-
#
|
|
30
|
-
# @return <String> This key value pair as a param
|
|
31
|
-
#
|
|
32
|
-
# @example normalize_param(:name, "Bob Jones") #=> "name=Bob%20Jones&"
|
|
33
|
-
def self.normalize_param(key, value)
|
|
34
|
-
param = ''
|
|
35
|
-
stack = []
|
|
36
|
-
|
|
37
|
-
if value.respond_to?(:to_ary)
|
|
38
|
-
param << value.to_ary.map { |element| normalize_param("#{key}[]", element) }.join
|
|
39
|
-
elsif value.respond_to?(:to_hash)
|
|
40
|
-
stack << [key, value.to_hash]
|
|
41
|
-
else
|
|
42
|
-
param << "#{key}=#{escape_value(value)}&"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
stack.each do |parent, hash|
|
|
46
|
-
hash.each do |k, v|
|
|
47
|
-
if v.respond_to?(:to_hash)
|
|
48
|
-
stack << ["#{parent}[#{k}]", v.to_hash]
|
|
49
|
-
else
|
|
50
|
-
param << normalize_param("#{parent}[#{k}]", v)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
param
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Prefer ERB::Util.url_encode, fall back to deprecation URI.encode for
|
|
59
|
-
# old Ruby support
|
|
60
|
-
def self.escape_value(value)
|
|
61
|
-
if ERB::Util.respond_to? :url_encode
|
|
62
|
-
ERB::Util.url_encode(value.to_s)
|
|
63
|
-
else
|
|
64
|
-
URI.encode(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|