marketing_connection 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08797661602cc367395af0ec760548dd2a12e1d4
4
+ data.tar.gz: 7e0e354e412036c6cfd5a2e563c6200619725287
5
+ SHA512:
6
+ metadata.gz: d9c14ea9f89a934f5fb8c1721b25f9bcdbb2fd625222f8b6ecfaf2d5c9514c0f908140dfa32d675590367efce34ee289a3b67bb83973f842cc4b7acf4dfd8b1d
7
+ data.tar.gz: 6607e8f47198140e32f5cd8659ea54a3786f21b234fd44bb8f9f80488d03e65c2028084621ad5c3d6be7c6362898fba29be837652cb57c2e9318115d54153964
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marketing_connection.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Erick
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,66 @@
1
+ # MarketingConnection
2
+
3
+ Gem to integrate marketing with a ruby project
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'marketing_connection'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install marketing_connection
18
+
19
+ ## Usage
20
+
21
+ #Intialize connection
22
+ marketing_connection = MarketingConnection::Base.new(api_key: "xx", api_secret: "yy")
23
+
24
+
25
+ ## Lists
26
+
27
+ #create a list
28
+ marketing_connection.lists.create(params)
29
+
30
+ #List index
31
+ marketing_connection.lists.list
32
+
33
+ #Find a list
34
+ marketing_connection.lists.find(list_id)
35
+
36
+ ## Templates
37
+
38
+ #create a list
39
+ marketing_connection.templates.create(params)
40
+
41
+ #List index
42
+ marketing_connection.templates.list
43
+
44
+ #Find a list
45
+ marketing_connection.templates.find(template_id)
46
+
47
+ ## Deliveries
48
+
49
+ #create a list
50
+ marketing_connection.deliveries.create(params)
51
+
52
+ #List index
53
+ marketing_connection.deliveries.list
54
+
55
+ #Find a list
56
+ marketing_connection.deliveries.find(list_id)
57
+
58
+
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,79 @@
1
+ require "marketing_connection/version"
2
+ require "marketing_connection/delivery"
3
+ require "marketing_connection/error"
4
+ require "marketing_connection/gun"
5
+ require "marketing_connection/list"
6
+ require "marketing_connection/template"
7
+
8
+ module MarketingConnection
9
+
10
+ class Base
11
+
12
+ def initialize(opts = {})
13
+ puts opts.inspect
14
+ end
15
+
16
+ def lists
17
+ MarketingConnection::List.new(self)
18
+ end
19
+
20
+ def deliveries
21
+ MarketingConnection::Delivery.new
22
+ end
23
+
24
+ def templates
25
+ MarketingConnection::Template.new(self)
26
+ end
27
+
28
+ def guns
29
+ MarketingConnection::Gun.new(self)
30
+ end
31
+
32
+ end
33
+
34
+
35
+
36
+
37
+ class << self
38
+ attr_accessor :api_key, :api_secret, :mode, :api_url
39
+
40
+ def mode
41
+ @mode || "demo"
42
+ end
43
+
44
+ def api_url
45
+ @api_url || "localhost:3008" #Still in dev
46
+ end
47
+
48
+ # Submits the API call to the Mailgun server
49
+ def submit(method, target_url, parameters={})
50
+ url = base_url + target_url
51
+ puts url
52
+ begin
53
+ parameters = {:params => parameters} if method == :get
54
+ return JSON(RestClient.send(method, url, parameters))
55
+ rescue => e
56
+ error_message = nil
57
+ if e.respond_to? :http_body
58
+ begin
59
+ error_message = JSON(e.http_body)["message"]
60
+ rescue
61
+ raise e
62
+ end
63
+ raise MarketingConnection::Error.new(error_message)
64
+ end
65
+ raise e
66
+ end
67
+ end
68
+
69
+ def base_url
70
+ "http://#{self.api_key}:#{self.api_secret}@#{self.api_url}/api/v1/"
71
+ end
72
+
73
+ def config
74
+ yield self
75
+ true
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,23 @@
1
+ module MarketingConnection
2
+ class Delivery
3
+
4
+ # def initailize(opts = {})
5
+ #
6
+ # end
7
+
8
+ def list(opts = {})
9
+ MarketingConnection.submit(:get, delivery_url, opts)
10
+ end
11
+
12
+ def create(params = {})
13
+ MarketingConnection.submit(:post, delivery_url, params)
14
+ end
15
+
16
+ private
17
+
18
+ def delivery_url
19
+ "deliveries"
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module MarketingConnection
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ module MarketingConnection
2
+ class Gun
3
+ def initialize(opts = {})
4
+ end
5
+
6
+ def list(opts = {})
7
+ MarketingConnection.submit(:get, gun_url, opts)
8
+ end
9
+
10
+ private
11
+ def gun_url
12
+ "guns"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module MarketingConnection
2
+ class List
3
+ def initialize(opts = {})
4
+
5
+ end
6
+
7
+ def list(opts = {})
8
+ MarketingConnection.submit(:get, list_url, opts)
9
+ end
10
+
11
+ def create(params = {})
12
+ MarketingConnection.submit(:post, list_url, params)
13
+ end
14
+
15
+ def update
16
+ end
17
+
18
+ def find(list_id)
19
+ MarketingConnection.submit(:get, "#{list_url}/#{list_id}")
20
+ end
21
+
22
+ private
23
+ def list_url
24
+ "lists"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module MarketingConnection
2
+ class Template
3
+ def initialize(opts = {})
4
+ end
5
+
6
+ def create
7
+ end
8
+
9
+ def list(opts = {})
10
+ MarketingConnection.submit(:get, template_url, opts)
11
+ end
12
+
13
+ def find(template_id)
14
+ MarketingConnection.submit(:get, "#{template_url}/#{template_id}")
15
+ end
16
+
17
+ def update
18
+ end
19
+
20
+ private
21
+ def template_url
22
+ "templates"
23
+ end
24
+
25
+
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module MarketingConnection
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'marketing_connection/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "marketing_connection"
8
+ spec.version = MarketingConnection::VERSION
9
+ spec.authors = ["Erick"]
10
+ spec.email = ["erick_8911@hotmail.com"]
11
+ spec.description = %q{MArketing conneciton}
12
+ spec.summary = %q{MArketing connection}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marketing_connection
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Erick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: MArketing conneciton
42
+ email:
43
+ - erick_8911@hotmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/marketing_connection.rb
54
+ - lib/marketing_connection/delivery.rb
55
+ - lib/marketing_connection/error.rb
56
+ - lib/marketing_connection/gun.rb
57
+ - lib/marketing_connection/list.rb
58
+ - lib/marketing_connection/template.rb
59
+ - lib/marketing_connection/version.rb
60
+ - marketing_connection.gemspec
61
+ homepage: ''
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.0.5
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: MArketing connection
85
+ test_files: []
86
+ has_rdoc: