usercycle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rvmrc +55 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/lib/usercycle.rb +21 -0
- data/lib/usercycle/event.rb +37 -0
- data/lib/usercycle/version.rb +3 -0
- data/usercycle.gemspec +19 -0
- metadata +66 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ruby-1.9.3-p0@usercycle"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment following line if you want options to be set only for given project.
|
11
|
+
#
|
12
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
13
|
+
|
14
|
+
#
|
15
|
+
# First we attempt to load the desired environment directly from the environment
|
16
|
+
# file. This is very fast and efficient compared to running through the entire
|
17
|
+
# CLI and selector. If you want feedback on which environment was used then
|
18
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
+
#
|
20
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
21
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
22
|
+
then
|
23
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
24
|
+
|
25
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
26
|
+
then
|
27
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
28
|
+
fi
|
29
|
+
else
|
30
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
31
|
+
if ! rvm --create use "$environment_id"
|
32
|
+
then
|
33
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
34
|
+
exit 1
|
35
|
+
fi
|
36
|
+
fi
|
37
|
+
|
38
|
+
#
|
39
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
40
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
41
|
+
# necessary.
|
42
|
+
#
|
43
|
+
# filename=".gems"
|
44
|
+
# if [[ -s "$filename" ]]
|
45
|
+
# then
|
46
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
47
|
+
# fi
|
48
|
+
|
49
|
+
# If you use bundler, this might be useful to you:
|
50
|
+
# if command -v bundle && [[ -s Gemfile ]]
|
51
|
+
# then
|
52
|
+
# bundle install
|
53
|
+
# fi
|
54
|
+
|
55
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
usercycle (0.0.1)
|
5
|
+
httparty (>= 0.8.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
httparty (0.8.1)
|
11
|
+
multi_json
|
12
|
+
multi_xml
|
13
|
+
multi_json (1.1.0)
|
14
|
+
multi_xml (0.4.1)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
usercycle!
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
## Install
|
2
|
+
|
3
|
+
```
|
4
|
+
$ gem install usercycle
|
5
|
+
```
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Setup
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
require 'usercycle'
|
13
|
+
|
14
|
+
# put your own credentials here
|
15
|
+
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
16
|
+
|
17
|
+
# set up a client to talk to the USERCycle API
|
18
|
+
@client = Usercycle::Client.new api_key
|
19
|
+
```
|
20
|
+
|
21
|
+
### List events by identity
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
identity = 'john.smith@example.com' #required
|
25
|
+
@client.event.find_by_identity(identity)
|
26
|
+
```
|
27
|
+
|
28
|
+
### Creating an event
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
identity = 'john.smith@example.com' #required
|
32
|
+
action = 'signed_up' #required
|
33
|
+
properties = { :first_name => 'John', :last_name => 'Smith' } #optional
|
34
|
+
@client.event.create(identity, action, properties)
|
35
|
+
```
|
36
|
+
|
37
|
+
## Full Documentation
|
38
|
+
|
39
|
+
For full API documentation visit the official USERCycle docs at http://docs.usercycle.com/rest_api
|
data/Rakefile
ADDED
data/lib/usercycle.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "usercycle/version"
|
3
|
+
require "usercycle/event"
|
4
|
+
|
5
|
+
|
6
|
+
module Usercycle
|
7
|
+
|
8
|
+
class Client
|
9
|
+
|
10
|
+
def initialize(key)
|
11
|
+
@api_key = key
|
12
|
+
self.class.headers 'X-Usercycle-API-Key' => @api_key
|
13
|
+
end
|
14
|
+
|
15
|
+
include HTTParty
|
16
|
+
include Event
|
17
|
+
|
18
|
+
base_uri "https://api.usercycle.com/api/v1"
|
19
|
+
format :json
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Usercycle
|
2
|
+
module Event
|
3
|
+
|
4
|
+
def event
|
5
|
+
@event ||= Event.new self
|
6
|
+
end
|
7
|
+
|
8
|
+
class Event
|
9
|
+
|
10
|
+
def initialize(client)
|
11
|
+
@client = client
|
12
|
+
end
|
13
|
+
|
14
|
+
# List events by identity
|
15
|
+
#
|
16
|
+
# client = Usercycle::Client.new(API_KEY)
|
17
|
+
# client.event.find_by_identity('john.smith@example.com')
|
18
|
+
#
|
19
|
+
def find_by_identity(identity, options={})
|
20
|
+
@client.class.get("/events.json?identity=#{identity}", options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Creating an event
|
24
|
+
#
|
25
|
+
# client = Usercycle::Client.new(API_KEY)
|
26
|
+
# client.event.create('john.smith@example.com', 'signed_up', :first_name => 'John', :last_name => 'Smith'
|
27
|
+
#
|
28
|
+
def create(identity, action, properties={})
|
29
|
+
options = { :body => {
|
30
|
+
:identity => identity,
|
31
|
+
:action => action,
|
32
|
+
:properties => properties }}
|
33
|
+
@client.class.post('/events.json', options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/usercycle.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/usercycle/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Caleb Woods"]
|
6
|
+
gem.email = ["calebawoods@gmail.com"]
|
7
|
+
gem.description = %q{Ruby Libray for interating with the USERCycle API}
|
8
|
+
gem.summary = %q{Library based of original rails plugin https://github.com/usercycle/usercycle-ruby-api}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "usercycle"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Usercycle::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency "httparty", ">= 0.8.1"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: usercycle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Caleb Woods
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: &70133955823640 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70133955823640
|
25
|
+
description: Ruby Libray for interating with the USERCycle API
|
26
|
+
email:
|
27
|
+
- calebawoods@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- .rvmrc
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/usercycle.rb
|
39
|
+
- lib/usercycle/event.rb
|
40
|
+
- lib/usercycle/version.rb
|
41
|
+
- usercycle.gemspec
|
42
|
+
homepage: ''
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.8.12
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Library based of original rails plugin https://github.com/usercycle/usercycle-ruby-api
|
66
|
+
test_files: []
|