tend-ruby 0.0.1
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 +7 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/lib/tend/errors/http_error.rb +10 -0
- data/lib/tend/errors/not_supported_error.rb +2 -0
- data/lib/tend/models/campaign.rb +16 -0
- data/lib/tend/models/contact.rb +47 -0
- data/lib/tend/models/garden.rb +50 -0
- data/lib/tend/models/page.rb +13 -0
- data/lib/tend/models/referrer.rb +20 -0
- data/lib/tend/models/segment.rb +24 -0
- data/lib/tend/models/visit.rb +13 -0
- data/lib/tend/util/ht.rb +58 -0
- data/lib/tend/util/no_delete.rb +16 -0
- data/lib/tend/util/no_find.rb +17 -0
- data/lib/tend/util/no_post.rb +17 -0
- data/lib/tend/util/no_update.rb +16 -0
- data/lib/tend/util/util.rb +53 -0
- data/lib/tend.rb +34 -0
- data/lib/version.rb +3 -0
- data/tend-ruby.gemspec +29 -0
- data/test/fixtures/campaign.json +15 -0
- data/test/fixtures/contact.json +13 -0
- data/test/fixtures/page.json +3 -0
- data/test/fixtures/referrer.json +11 -0
- data/test/fixtures/segment.json +21 -0
- data/test/fixtures/vcr/campaign_all.yml +67 -0
- data/test/fixtures/vcr/campaign_contacts.yml +39 -0
- data/test/fixtures/vcr/campaign_delete.yml +39 -0
- data/test/fixtures/vcr/campaign_find.yml +40 -0
- data/test/fixtures/vcr/campaign_update.yml +39 -0
- data/test/fixtures/vcr/campaign_visits.yml +40 -0
- data/test/fixtures/vcr/contact_all.yml +41 -0
- data/test/fixtures/vcr/contact_delete.yml +41 -0
- data/test/fixtures/vcr/contact_find.yml +41 -0
- data/test/fixtures/vcr/contact_segments.yml +39 -0
- data/test/fixtures/vcr/contact_update.yml +42 -0
- data/test/fixtures/vcr/contact_visits.yml +89 -0
- data/test/fixtures/vcr/page_all.yml +39 -0
- data/test/fixtures/vcr/referrer_all.yml +39 -0
- data/test/fixtures/vcr/referrer_contacts.yml +39 -0
- data/test/fixtures/vcr/referrer_find.yml +39 -0
- data/test/fixtures/vcr/referrer_visits.yml +39 -0
- data/test/fixtures/vcr/segment_all.yml +43 -0
- data/test/fixtures/vcr/segment_assign_as_array.yml +39 -0
- data/test/fixtures/vcr/segment_assign_as_strings.yml +39 -0
- data/test/fixtures/vcr/segment_assign_one_array.yml +39 -0
- data/test/fixtures/vcr/segment_assign_one_string.yml +39 -0
- data/test/fixtures/vcr/segment_create.yml +40 -0
- data/test/fixtures/vcr/segment_delete.yml +39 -0
- data/test/fixtures/vcr/segment_detach_as_array.yml +39 -0
- data/test/fixtures/vcr/segment_detach_as_strings.yml +39 -0
- data/test/fixtures/vcr/segment_detach_one_array.yml +39 -0
- data/test/fixtures/vcr/segment_detach_one_string.yml +39 -0
- data/test/fixtures/vcr/segment_find.yml +39 -0
- data/test/fixtures/vcr/segment_update.yml +39 -0
- data/test/fixtures/vcr/visit_all.yml +89 -0
- data/test/fixtures/visit.json +3 -0
- data/test/helpers/all.rb +18 -0
- data/test/helpers/no_create.rb +20 -0
- data/test/helpers/no_delete.rb +20 -0
- data/test/helpers/no_find.rb +20 -0
- data/test/helpers/no_update.rb +20 -0
- data/test/models/campaign_test.rb +37 -0
- data/test/models/contact_test.rb +36 -0
- data/test/models/page_test.rb +11 -0
- data/test/models/referrer_test.rb +25 -0
- data/test/models/segment_test.rb +62 -0
- data/test/models/visit_test.rb +12 -0
- data/test/test_helper.rb +81 -0
- metadata +264 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8371ebedf83498b8009b0eab198d55cea5ead22
|
4
|
+
data.tar.gz: f35a63e52f9743f67b017ccb4c7988c1f5394107
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27662f774c18274913cbcca6699f7d8e595cf299967109e7f8bf06ba2e34c3afff2bb7a2e170178b4b75a38a84a4939e12eff2de51a8c361855deb60eb7d17fb
|
7
|
+
data.tar.gz: 0107a58b4d1c6e8d702b7fd8d90875bab9c842650b92d599c1d6c25e4a8add7da704ccb14dc23a4657f732fcbb7064422166572573d664fc06ef3cb446b99705
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
x.rb
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
.rvmrc
|
24
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Allan Branch
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 stevenbristol
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Tend-Ruby
|
2
|
+
|
3
|
+
Ruby wrapper of Tend.io API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'tend-ruby'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install tend-ruby
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
* Add Tend user name and password:
|
22
|
+
|
23
|
+
`
|
24
|
+
Tend.user_name = "brian"
|
25
|
+
Tend.password = "sdnf9283*hwer"
|
26
|
+
`
|
27
|
+
|
28
|
+
* View all contacts
|
29
|
+
|
30
|
+
$Tend::Contact.all
|
31
|
+
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/lesseverything/tend-ruby/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
class Tend::Campaign < Tend::Garden
|
3
|
+
include Tend::Util::NoPost
|
4
|
+
|
5
|
+
ATTRIBUTES = [:id, :domain, :name, :source, :medium, :term, :content, :start, :end, :image, :notes]
|
6
|
+
attr_accessor :attributes, *ATTRIBUTES
|
7
|
+
|
8
|
+
def visits options = {}
|
9
|
+
collection "visits", Tend::Visit, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def contacts options = {}
|
13
|
+
collection "contacts", Tend::Contact, options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
class Tend::Contact < Tend::Garden
|
3
|
+
include Tend::Util::NoPost
|
4
|
+
|
5
|
+
ATTRIBUTES = [:id, :name, :firstName, :lastName, :email, :company, :title, :bio, :website, :address, :city, :state, :zip, :country, :photo, :facebook, :twitter, :linkedin, :activity, :segments, :referrers, :campaigns]
|
6
|
+
|
7
|
+
attr_accessor :attributes, *ATTRIBUTES
|
8
|
+
|
9
|
+
def initialize *args
|
10
|
+
init(*args) do |att, value|
|
11
|
+
case att
|
12
|
+
when :segments
|
13
|
+
a = []
|
14
|
+
value.each do |h|
|
15
|
+
a << Tend::Segment.new( h )
|
16
|
+
end
|
17
|
+
@segments = a
|
18
|
+
when :campaign
|
19
|
+
a = []
|
20
|
+
value.each do |h|
|
21
|
+
a << Tend::Campaign.new( h )
|
22
|
+
end
|
23
|
+
@campaigns = a
|
24
|
+
when :referrer
|
25
|
+
a = []
|
26
|
+
value.each do |h|
|
27
|
+
a << Tend::Referrer.new( h )
|
28
|
+
end
|
29
|
+
@referrers = a
|
30
|
+
else
|
31
|
+
send("#{att}=", value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def visits options = {}
|
37
|
+
return @visits if @visits && !options.delete(:reload)
|
38
|
+
collection "visits", Tend::Visit, options
|
39
|
+
end
|
40
|
+
|
41
|
+
def segments options = {}
|
42
|
+
return @segments if @segments && !options.delete(:reload)
|
43
|
+
collection "segments", Tend::Segment, options
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
class Tend::Garden
|
3
|
+
include Tend::Util::Ht
|
4
|
+
include Tend::Util::Util
|
5
|
+
|
6
|
+
attr_accessor :attributes
|
7
|
+
def initialize attributes
|
8
|
+
a = HashWithIndifferentAccess.new attributes
|
9
|
+
init(a) do |att, value|
|
10
|
+
send("#{att}=", value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def all options = {}
|
16
|
+
response = get options
|
17
|
+
#return response
|
18
|
+
response.map { |object| new(object) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def find id, options = {}
|
22
|
+
new( get( options.merge(id: id, no_pagination: true) ) )
|
23
|
+
end
|
24
|
+
|
25
|
+
def create attributes, options = {}
|
26
|
+
new( post attributes, options )
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
|
34
|
+
def init attributes
|
35
|
+
@attributes = attributes
|
36
|
+
@attributes.each do |att, value|
|
37
|
+
yield att, value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection name, cla, options = {}
|
42
|
+
response = get options.merge(collection: name, id: id)
|
43
|
+
a = []
|
44
|
+
response.each do |h|
|
45
|
+
a << cla.new(h)
|
46
|
+
end
|
47
|
+
a
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
class Tend::Referrer < Tend::Garden
|
3
|
+
include Tend::Util::NoPost
|
4
|
+
include Tend::Util::NoUpdate
|
5
|
+
include Tend::Util::NoDelete
|
6
|
+
|
7
|
+
ATTRIBUTES = [:id, :name]
|
8
|
+
attr_accessor *ATTRIBUTES
|
9
|
+
|
10
|
+
|
11
|
+
def visits options = {}
|
12
|
+
collection "visits", Tend::Visit, options
|
13
|
+
end
|
14
|
+
|
15
|
+
def contacts options = {}
|
16
|
+
collection "contacts", Tend::Contact, options
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
class Tend::Segment < Tend::Garden
|
3
|
+
|
4
|
+
ATTRIBUTES = [:id, :name]
|
5
|
+
attr_accessor :attributes, *ATTRIBUTES
|
6
|
+
|
7
|
+
def self.assign email, segments = [], options = {}
|
8
|
+
call_remote_method "assign", email, segments, options = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.detach email, segments = [], options = {}
|
12
|
+
call_remote_method "detach", email, segments, options = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def self.call_remote_method remote_method, email, segments = [], options = {}
|
18
|
+
segs = segments.split(",").join(",")
|
19
|
+
post( {email: email, segments: segs}, options.merge(collection: remote_method, no_pagination: true))
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
class Tend::Visit < Tend::Garden
|
3
|
+
include Tend::Util::NoPost
|
4
|
+
include Tend::Util::NoUpdate
|
5
|
+
include Tend::Util::NoDelete
|
6
|
+
include Tend::Util::NoFind
|
7
|
+
|
8
|
+
ATTRIBUTES = [:id, :domain, :page, :query, :referrer, :campaign, :date]
|
9
|
+
attr_accessor :attributes, *ATTRIBUTES
|
10
|
+
|
11
|
+
|
12
|
+
end
|
13
|
+
|
data/lib/tend/util/ht.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
module Tend::Util::Ht
|
3
|
+
include HTTParty
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
def get options = {}
|
7
|
+
o = extract_options options
|
8
|
+
handle_response( HTTParty.get( uri(o), :basic_auth => o.auth ) )
|
9
|
+
end
|
10
|
+
|
11
|
+
def post attributes, options = {}
|
12
|
+
o = extract_options options
|
13
|
+
o.no_pagination = true
|
14
|
+
handle_response( HTTParty.post( uri(o), body: attributes, :basic_auth => o.auth ) )
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def handle_response response
|
21
|
+
case response.code
|
22
|
+
when 200..299
|
23
|
+
#p response
|
24
|
+
response.parsed_response["data"] || response.parsed_response["message"]
|
25
|
+
when 422
|
26
|
+
HashWithIndifferentAccess.new response.parsed_response
|
27
|
+
else
|
28
|
+
raise Tend::HttpError.new("#{response.response.message} #{response.code}", response.code, response)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
module InstanceMethods
|
35
|
+
|
36
|
+
def delete options = {}
|
37
|
+
o = extract_options options.merge(id: id, no_pagination: true)
|
38
|
+
initialize self.class.send( :handle_response, HTTParty.delete( uri(o), :basic_auth => o.auth ) )
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def update attributes, options = {}
|
43
|
+
o = extract_options options.merge(id: id, no_pagination: true)
|
44
|
+
initialize self.class.send( :handle_response, HTTParty.put( uri(o), body: attributes, :basic_auth => o.auth ) )
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
def get options = {}
|
49
|
+
self.class.get options
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.included(receiver)
|
55
|
+
receiver.extend ClassMethods
|
56
|
+
receiver.send :include, InstanceMethods
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Tend::Util::NoDelete
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
module InstanceMethods
|
7
|
+
def delete *args
|
8
|
+
raise Tend::NotSupportedError.new("Delete method is not supported on this object.")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included(receiver)
|
13
|
+
receiver.extend ClassMethods
|
14
|
+
receiver.send :include, InstanceMethods
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tend::Util::NoFind
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
def find *args
|
5
|
+
raise Tend::NotSupportedError.new("Find method is not supported on this object.")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(receiver)
|
14
|
+
receiver.extend ClassMethods
|
15
|
+
receiver.send :include, InstanceMethods
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tend::Util::NoPost
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
def post *args
|
5
|
+
raise Tend::NotSupportedError.new("Post method is not supported on this object.")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(receiver)
|
14
|
+
receiver.extend ClassMethods
|
15
|
+
receiver.send :include, InstanceMethods
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Tend::Util::NoUpdate
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
module InstanceMethods
|
7
|
+
def update *args
|
8
|
+
raise Tend::NotSupportedError.new("Update method is not supported on this object.")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included(receiver)
|
13
|
+
receiver.extend ClassMethods
|
14
|
+
receiver.send :include, InstanceMethods
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Tend::Util::Util
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
private
|
7
|
+
def extract_options options = {}
|
8
|
+
o = OpenStruct.new({
|
9
|
+
page: options[:page] || 1,
|
10
|
+
user_name: options[:user_name] || Tend.user_name,
|
11
|
+
password: options[:password] || Tend.password,
|
12
|
+
id: options[:id],
|
13
|
+
collection: options[:collection],
|
14
|
+
no_pagination: options[:no_pagination]
|
15
|
+
})
|
16
|
+
o.auth ={:username => o.user_name, :password => o.password}
|
17
|
+
o
|
18
|
+
end
|
19
|
+
|
20
|
+
def uri options
|
21
|
+
u = "#{Tend::URI}#{self.to_s.gsub("Tend::", "").downcase.pluralize}"
|
22
|
+
if options.id
|
23
|
+
u += "/#{options.id}"
|
24
|
+
end
|
25
|
+
if options.collection
|
26
|
+
u += "/#{options.collection}" if options.collection
|
27
|
+
end
|
28
|
+
if !options.no_pagination
|
29
|
+
u += "?page=#{options.page}"
|
30
|
+
end
|
31
|
+
u
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
module InstanceMethods
|
37
|
+
|
38
|
+
private
|
39
|
+
def extract_options options = {}
|
40
|
+
self.class.send :extract_options, options
|
41
|
+
end
|
42
|
+
|
43
|
+
def uri options
|
44
|
+
self.class.send :uri, options
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.included(receiver)
|
50
|
+
receiver.extend ClassMethods
|
51
|
+
receiver.send :include, InstanceMethods
|
52
|
+
end
|
53
|
+
end
|
data/lib/tend.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
require "version"
|
3
|
+
require "httparty"
|
4
|
+
require "active_support"
|
5
|
+
require "active_support/core_ext"
|
6
|
+
|
7
|
+
module Tend::Util
|
8
|
+
end
|
9
|
+
|
10
|
+
require "tend/util/ht"
|
11
|
+
require "tend/util/util"
|
12
|
+
require "tend/util/no_post"
|
13
|
+
require "tend/util/no_update"
|
14
|
+
require "tend/util/no_delete"
|
15
|
+
require "tend/util/no_find"
|
16
|
+
require "tend/errors/http_error"
|
17
|
+
require "tend/errors/not_supported_error"
|
18
|
+
require "tend/models/garden"
|
19
|
+
require "tend/models/campaign"
|
20
|
+
require "tend/models/contact"
|
21
|
+
require "tend/models/page"
|
22
|
+
require "tend/models/segment"
|
23
|
+
require "tend/models/referrer"
|
24
|
+
require "tend/models/visit"
|
25
|
+
|
26
|
+
module Tend
|
27
|
+
|
28
|
+
URI = "https://tend.io/api/v1/"
|
29
|
+
|
30
|
+
class << self
|
31
|
+
attr_accessor :user_name, :password
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/lib/version.rb
ADDED
data/tend-ruby.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tend-ruby"
|
8
|
+
spec.version = Tend::VERSION
|
9
|
+
spec.authors = ["stevenbristol"]
|
10
|
+
spec.email = ["stevenbristol@gmail.com"]
|
11
|
+
spec.summary = "Ruby version of Tend.io API"
|
12
|
+
spec.description = "Ruby version of Tend.io API"
|
13
|
+
spec.homepage = "https://github.com/LessEverything/tend-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "vcr"
|
24
|
+
spec.add_development_dependency "webmock"
|
25
|
+
|
26
|
+
spec.add_runtime_dependency "httparty", "~> 0.13"
|
27
|
+
spec.add_runtime_dependency "json", "~> 1.8"
|
28
|
+
spec.add_runtime_dependency "activesupport", ">= 0"
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
{
|
3
|
+
|
4
|
+
"delete":{"id":1,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},
|
5
|
+
|
6
|
+
"visits":[{"id":"11","domain":"lesschurn.io","page":"\/url","referrer":"LC","campaign":"test2","date":"2015-08-27 18:01:18"}],
|
7
|
+
|
8
|
+
"update":{"id":1,"domain":"http://lesschurn.io","name":"xxxxx","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},
|
9
|
+
|
10
|
+
"find":{"id":1,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},
|
11
|
+
|
12
|
+
"contacts":[],
|
13
|
+
|
14
|
+
"all":[{"id":112,"domain":"http://lesschurn.io","name":"xxxxx","source":"email_sig","medium":"email","term":"","content":"","start":"","end":"","image":"","notes":""},{"id":94420,"domain":"http://lesschurn.io","name":"Daily-Hunt","source":"Learn-and-Launch_Issue-9","medium":"web","term":"","content":"","start":"","end":"","image":"","notes":""},{"id":116061,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":1,"domain":"http://lesschurn.io","name":"xxxxx","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":116063,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":116081,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":116085,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":116093,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":116107,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":116143,"domain":"http://lesschurn.io","name":"Losing customers sucks","source":"LC+cold","medium":"outreach","term":"","content":"LessChurn","start":"","end":"","image":"","notes":""},{"id":116191,"domain":"http://lesschurn.io","name":"Losing customers sucks","source":"LC+cold","medium":"outreach","term":"","content":"LessChurn","start":"","end":"","image":"","notes":""},{"id":116357,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":117538,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":117539,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":117648,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":118747,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":118984,"domain":"http://lesschurn.io","name":"xxxxx","source":"twitter.com","medium":"social","term":"","content":"buffer58b29","start":"","end":"","image":"","notes":""},{"id":119792,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":128233,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":133441,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":138664,"domain":"http://lesschurn.io","name":"xxxxx","source":"facebook.com","medium":"social","term":"","content":"buffer6ac56","start":"","end":"","image":"","notes":""},{"id":146253,"domain":"http://lesschurn.io","name":"xxxxx","source":"facebook","medium":"retargetingbanner","term":"","content":"videopicture","start":"","end":"","image":"","notes":""},{"id":219228,"domain":"http://lesschurn.io","name":"losing customers sucks","source":"LC","medium":"outreach","term":"","content":"lesschurn","start":"","end":"","image":"","notes":""},{"id":242270,"domain":"http://lesschurn.io","name":"getting-customers-is-not-the-hardest-part-of-saas","source":"customer-retention-crash-course","medium":"drip","term":"","content":"","start":"","end":"","image":"","notes":""},{"id":268829,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":268872,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":268878,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":269066,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":269166,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":269217,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":272765,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":272813,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":272973,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""},{"id":273648,"domain":"http://lesschurn.io","name":"Losing customers sucks","source":"LC+cold","medium":"outreach","term":"","content":"LessChurn","start":"","end":"","image":"","notes":""},{"id":279768,"domain":"http://lesschurn.io","name":"Churn University","source":"LC","medium":"outreach","term":"","content":"Churn%20University","start":"","end":"","image":"","notes":""}]
|
15
|
+
}
|