remetric 0.0.13 → 1.0.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/.gitignore +9 -1
- data/Gemfile +0 -2
- data/README.md +13 -26
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/remetric.rb +6 -39
- data/lib/remetric/client.rb +71 -0
- data/lib/remetric/endpoints/endpoint.rb +19 -0
- data/lib/remetric/endpoints/rest.rb +36 -0
- data/lib/remetric/endpoints/user.rb +11 -0
- data/lib/remetric/http.rb +61 -0
- data/lib/remetric/version.rb +2 -2
- data/remetric.gemspec +12 -9
- metadata +35 -16
- data/LICENSE.txt +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126146869bea224d84523a2be545dc5b5c58a7f9
|
4
|
+
data.tar.gz: 931599e907e108a65798e346d1fa5644e5f4c2f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c37dc322bf4b82d06232e5954ca003886766ab0003a4b57e17accbc72e54230bdab75b7dcde559b396d33e477908a8a5d56c51ae813ff529ec092493f688bb7
|
7
|
+
data.tar.gz: e6db2c780a24113edc5e1203b61e2a8e06609cd5311eb65bd6c616a61ed10811782b52ecef15df0884216d3381b740936bcd593ee734cf183964260d00b753cb
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
# Remetric
|
2
2
|
|
3
|
-
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/remetric`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
|
-
|
11
|
+
```ruby
|
12
|
+
gem 'remetric'
|
13
|
+
```
|
12
14
|
|
13
15
|
And then execute:
|
14
16
|
|
@@ -20,30 +22,15 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
25
|
+
TODO: Write usage instructions here
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
email: user.email,
|
31
|
-
name: user.name,
|
32
|
-
last_sign_in: Time.now.to_i,
|
33
|
-
comments: user.comments.count
|
34
|
-
}
|
35
|
-
|
36
|
-
r.save_contact({
|
37
|
-
key: user.id,
|
38
|
-
email: user.email,
|
39
|
-
name: user.name
|
40
|
-
})
|
41
|
-
```
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
32
|
|
43
33
|
## Contributing
|
44
34
|
|
45
|
-
|
46
|
-
|
47
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
-
5. Create new Pull Request
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/remetric.
|
36
|
+
|
data/Rakefile
CHANGED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "remetric"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/remetric.rb
CHANGED
@@ -1,42 +1,9 @@
|
|
1
1
|
require "remetric/version"
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
2
|
+
require "remetric/client"
|
3
|
+
require "remetric/http"
|
4
|
+
require "remetric/endpoints/endpoint"
|
5
|
+
require "remetric/endpoints/rest"
|
6
|
+
require "remetric/endpoints/user"
|
5
7
|
|
6
|
-
|
7
|
-
def initialize api_key, sandbox = false
|
8
|
-
@rm_api_key = api_key
|
9
|
-
@rm_sandbox = sandbox
|
10
|
-
end
|
11
|
-
|
12
|
-
def api_key
|
13
|
-
@rm_api_key
|
14
|
-
end
|
15
|
-
|
16
|
-
def track data = {}
|
17
|
-
begin
|
18
|
-
RestClient.get "#{endpoint}/track/img/#{to_base64 data}"
|
19
|
-
rescue
|
20
|
-
{ errors: "You are unauthorized." }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def img data = {}
|
25
|
-
src = "#{endpoint}/track/img/#{to_base64 data}"
|
26
|
-
img = "<img src=\"#{src}\" style=\"display: none; \">"
|
27
|
-
img
|
28
|
-
end
|
29
|
-
|
30
|
-
def redirect data = {}
|
31
|
-
"#{endpoint}/track/redirect/#{to_base64 data}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_base64 data = {}
|
35
|
-
data["publishable_key"] = api_key
|
36
|
-
URI.escape Base64.encode64(JSON.generate(data))
|
37
|
-
end
|
38
|
-
|
39
|
-
def endpoint
|
40
|
-
@rm_sandbox ? "http://localhost:3000" : "https://secure.remetric.com"
|
41
|
-
end
|
8
|
+
module Remetric
|
42
9
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Remetric
|
2
|
+
class Client
|
3
|
+
def initialize(opts = {})
|
4
|
+
@account = opts[:account]
|
5
|
+
@api_token = opts[:api_token]
|
6
|
+
@secret_key = opts[:secret_key]
|
7
|
+
@debug = opts[:debug]
|
8
|
+
end
|
9
|
+
|
10
|
+
def account
|
11
|
+
@account
|
12
|
+
end
|
13
|
+
|
14
|
+
def account=(account)
|
15
|
+
@account = account
|
16
|
+
end
|
17
|
+
|
18
|
+
def api_token
|
19
|
+
@api_token
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_token=(api_token)
|
23
|
+
@api_token = api_token
|
24
|
+
end
|
25
|
+
|
26
|
+
def secret_key
|
27
|
+
@secret_key
|
28
|
+
end
|
29
|
+
|
30
|
+
def secret_key=(secret_key)
|
31
|
+
@secret_key = secret_key
|
32
|
+
end
|
33
|
+
|
34
|
+
def debug
|
35
|
+
@debug
|
36
|
+
end
|
37
|
+
|
38
|
+
def debug=(debug)
|
39
|
+
@debug = debug
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_json
|
43
|
+
{
|
44
|
+
account: @account,
|
45
|
+
api_token: @api_token,
|
46
|
+
secret_key: @secret_key,
|
47
|
+
debug: @debug
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def http
|
52
|
+
Remetric::HTTP.new self
|
53
|
+
end
|
54
|
+
|
55
|
+
def user
|
56
|
+
@user ||= Remetric::UserEndpoint.new self
|
57
|
+
end
|
58
|
+
|
59
|
+
def events
|
60
|
+
@events ||= Remetric::RESTEndpoint.new :events, self
|
61
|
+
end
|
62
|
+
|
63
|
+
def sequences
|
64
|
+
@events ||= Remetric::RESTEndpoint.new :events, self
|
65
|
+
end
|
66
|
+
|
67
|
+
def ctas
|
68
|
+
@ctas ||= Remetric::RESTEndpoint.new :ctas, self
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Remetric
|
2
|
+
class RESTEndpoint < Remetric::Endpoint
|
3
|
+
def initialize(resource, client)
|
4
|
+
@resource = resource
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
def resource
|
9
|
+
@resource
|
10
|
+
end
|
11
|
+
|
12
|
+
def resource=(resource)
|
13
|
+
@resource = resource
|
14
|
+
end
|
15
|
+
|
16
|
+
def list(args = {})
|
17
|
+
http.get "/#{client.account}/#{resource}", args
|
18
|
+
end
|
19
|
+
|
20
|
+
def show(id)
|
21
|
+
http.get "/#{client.account}/#{resource}/#{id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(args = {})
|
25
|
+
http.post "/#{client.account}/#{resource}", { event: args }
|
26
|
+
end
|
27
|
+
|
28
|
+
def update(id, args = {})
|
29
|
+
http.patch "/#{client.account}/#{resource}/#{id}", { event: args }
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy(id)
|
33
|
+
http.delete "/#{client.account}/#{resource}/#{id}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'base64'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Remetric
|
6
|
+
class HTTP
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
def client
|
12
|
+
@client
|
13
|
+
end
|
14
|
+
|
15
|
+
def root_url
|
16
|
+
# return "http://localhost:3000"
|
17
|
+
"https://api.remetric.com"
|
18
|
+
end
|
19
|
+
|
20
|
+
def rc
|
21
|
+
@rc ||= RestClient
|
22
|
+
end
|
23
|
+
|
24
|
+
def headers
|
25
|
+
{
|
26
|
+
Authorization: "Basic #{Base64.encode64("#{client.api_token}:#{client.secret_key}")}"
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def opts
|
31
|
+
{
|
32
|
+
content_type: :json,
|
33
|
+
accept: :json
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse(response)
|
38
|
+
JSON.parse response.body
|
39
|
+
end
|
40
|
+
|
41
|
+
def get(path, args = {})
|
42
|
+
response = rc.get "#{root_url}#{path}", headers.merge(params: args)
|
43
|
+
parse response
|
44
|
+
end
|
45
|
+
|
46
|
+
def post(path, args = {})
|
47
|
+
response = rc.post "#{root_url}#{path}", args, headers
|
48
|
+
parse response
|
49
|
+
end
|
50
|
+
|
51
|
+
def patch(path, args = {})
|
52
|
+
response = rc.patch "#{root_url}#{path}", args, headers
|
53
|
+
parse response
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete(path)
|
57
|
+
response = rc.delete "#{root_url}#{path}", headers
|
58
|
+
parse response
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/remetric/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0
|
1
|
+
module Remetric
|
2
|
+
VERSION = "1.0.0"
|
3
3
|
end
|
data/remetric.gemspec
CHANGED
@@ -7,17 +7,20 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "remetric"
|
8
8
|
spec.version = Remetric::VERSION
|
9
9
|
spec.authors = ["Dallas Read"]
|
10
|
-
spec.email = ["dallas@
|
11
|
-
|
12
|
-
spec.summary = %q{
|
10
|
+
spec.email = ["dallas@excitecreative.ca"]
|
11
|
+
|
12
|
+
spec.summary = %q{Interact with the Remetric API.}
|
13
|
+
spec.description = %q{Interact with the Remetric API.}
|
13
14
|
spec.homepage = "http://www.remetric.com"
|
14
|
-
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
17
|
-
|
18
|
-
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
21
|
spec.require_paths = ["lib"]
|
20
22
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_dependency "rest-client", "~> 2.0.0"
|
23
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remetric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dallas Read
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,46 +16,65 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.14'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
description:
|
54
|
+
version: 2.0.0
|
55
|
+
description: Interact with the Remetric API.
|
42
56
|
email:
|
43
|
-
- dallas@
|
57
|
+
- dallas@excitecreative.ca
|
44
58
|
executables: []
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- ".gitignore"
|
49
63
|
- Gemfile
|
50
|
-
- LICENSE.txt
|
51
64
|
- README.md
|
52
65
|
- Rakefile
|
66
|
+
- bin/console
|
67
|
+
- bin/setup
|
53
68
|
- lib/remetric.rb
|
69
|
+
- lib/remetric/client.rb
|
70
|
+
- lib/remetric/endpoints/endpoint.rb
|
71
|
+
- lib/remetric/endpoints/rest.rb
|
72
|
+
- lib/remetric/endpoints/user.rb
|
73
|
+
- lib/remetric/http.rb
|
54
74
|
- lib/remetric/version.rb
|
55
75
|
- remetric.gemspec
|
56
76
|
homepage: http://www.remetric.com
|
57
|
-
licenses:
|
58
|
-
- MIT
|
77
|
+
licenses: []
|
59
78
|
metadata: {}
|
60
79
|
post_install_message:
|
61
80
|
rdoc_options: []
|
@@ -73,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
92
|
version: '0'
|
74
93
|
requirements: []
|
75
94
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.5.2
|
77
96
|
signing_key:
|
78
97
|
specification_version: 4
|
79
|
-
summary:
|
98
|
+
summary: Interact with the Remetric API.
|
80
99
|
test_files: []
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Dallas Read
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|