unbounce 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6e68db8658b1ee575f0f3d245aa237d2856d91c
4
+ data.tar.gz: aec876d9c49fb7f3bed9e1bc25fbf99082bb94ca
5
+ SHA512:
6
+ metadata.gz: 4cbf7abb6a45d19ded5174daf6a9ca91e412fbd8c990ebe5f343a4331ec32c2e5d62cc6ab278096c8f94b39e226dc50d997a6f018a3076e2b5d6baa8fc477c09
7
+ data.tar.gz: 6d8739426262827ad3e278000bcbf9670f74065168af3122345194d96d97a73b012ee5d8a526e4f1c9d720755b53fc3f8fa65cc8cb1125efa4b435e8a91e56e9
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ test.rb
14
+ *.gem
15
+
16
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mhoskison@etnainteractive.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in unbounce.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Michael Hoskison
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,155 @@
1
+ # unbounce
2
+
3
+ Simple GEM to access the Unbounce API. (https://unbounce.com/)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'unbounce'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install unbounce
20
+
21
+ ## Usage
22
+
23
+ ### Setting Connection
24
+
25
+ ###### Required value
26
+ * key: Your Unbounce API key.
27
+ ###### Optional
28
+ * api_url:
29
+ Defaults to https://api.unbounce.com
30
+ * api_version:
31
+ Defaults to 0.4
32
+
33
+ ```ruby
34
+ opts = {key: "<Your unbounce API Key>"}
35
+ testcon = Unbounce::Api.new(:key => opts[:key])
36
+ ```
37
+
38
+ ### Query Parameters
39
+
40
+ ###### sort_order
41
+ * asc - Default
42
+ * desc
43
+ ###### count
44
+ When true, don't return the response's collection attribute.
45
+ ###### from
46
+ Limit results to those created after from. Example: 2014-12-31T00:00:00.000Z
47
+ ###### to
48
+ Limit results to those created before to. Example: 2014-12-31T23:59:59.999Z
49
+ ###### offset
50
+ Omit the first offset number of results. Example: 3
51
+ ###### limit
52
+ Only return limit number of results. Example: 100, Default set to Maximum of 1000
53
+ ###### with_stats
54
+ When true, include page stats for the collection.
55
+ ###### role
56
+ Restricts the scope of the returned pages. one of viewer, author
57
+ ###### include_sub_pages
58
+ When true, include sub page form fields in the response
59
+
60
+ ### Get Accounts
61
+ Retrieve the accounts collection.
62
+
63
+ Supported Params:
64
+ * sort_order
65
+
66
+ ```ruby
67
+ testcon.get_accounts
68
+ ```
69
+
70
+ ### Get Pages
71
+ ###### All Pages
72
+ Retrieve a list of all pages.
73
+
74
+ Supported Params:
75
+ * sort_order
76
+ * count
77
+ * from
78
+ * to
79
+ * offset
80
+ * limit
81
+ * with_stats
82
+ * role
83
+
84
+ ```ruby
85
+ testcon.get_pages()
86
+ ```
87
+ ###### All Pages for specific account
88
+ ```ruby
89
+ opts = {account_id: <account_id>}
90
+ testcon.get_pages(opts)
91
+ ```
92
+ ###### Specific page
93
+ ```ruby
94
+ opts = {page_id: <page_id>}
95
+ testcon.get_pages(opts)
96
+ ```
97
+ ###### Page Form Fields
98
+ Retrieve a full list of all form fields across all page variants of a specific page.
99
+
100
+ Supported Params:
101
+ * sort_order
102
+ * count
103
+ * include_sub_pages
104
+
105
+ ```ruby
106
+ opts = {page_id: <page_id>, form_fields: true}
107
+ testcon.get_pages(opts)
108
+ ```
109
+
110
+ ### Get Leads
111
+ ###### All for page
112
+ Retrieve a list of all leads for a given page.
113
+
114
+ Supported Params:
115
+ * sort_order
116
+ * count
117
+ * from
118
+ * to
119
+ * offset
120
+ * limit
121
+
122
+ ```ruby
123
+ opts = {page_id: <page_id>}
124
+ testcon.get_leads(opts)
125
+ ```
126
+ ###### Single Lead
127
+ Retrieve a single lead.
128
+
129
+ ```ruby
130
+ opts = {lead_id: <lead_id>}
131
+ testcon.get_leads(opts)
132
+ ```
133
+
134
+
135
+ ## Version History
136
+ # v0.1.0
137
+ Initial work for retrieving accounts, pages, and leads.
138
+
139
+ ## Development
140
+
141
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
142
+
143
+ 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).
144
+
145
+ ## Contributing
146
+
147
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mhoskiso/unbounce. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
148
+
149
+ ## License
150
+
151
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
152
+
153
+ ## Code of Conduct
154
+
155
+ Everyone interacting in the Unbounce project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mhoskiso/unbounce/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "unbounce"
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,105 @@
1
+ require 'bundler/setup'
2
+ require "unbounce/version"
3
+ require 'json'
4
+ require 'ostruct'
5
+ require 'rest-client'
6
+ require "base64"
7
+
8
+ module Unbounce
9
+ class Api
10
+
11
+ MAX_RESULT_LIMIT = '1000'
12
+
13
+ def initialize(opts = {})
14
+ api_version = opts[:api_version].nil? ? "application/vnd.unbounce.api.v0.4+json" : "application/vnd.unbounce.api.v#{opts[:api_version]}+json"
15
+ @headers = {Accept: api_version}
16
+ @url = opts[:api_url].nil? ? "https://api.unbounce.com" : opts[:api_url]
17
+ @auth = 'Basic ' + Base64.encode64(opts[:key]).chomp
18
+ @account_id = opts[:account_id].to_s if opts[:account_id]
19
+
20
+ # -H "Accept: application/vnd.unbounce.api.v0.4+json"
21
+ end
22
+
23
+ def set_account_id(opts = {})
24
+ @account_id = opts[:account_id].to_s
25
+ end
26
+
27
+ def parse_json(response)
28
+ body = JSON.parse(response.to_str) if response.code == 200
29
+ OpenStruct.new(code: response.code, body: body)
30
+ end
31
+
32
+ def set_params(opts = {})
33
+ params = {}
34
+ #Result params
35
+ params[:path] = opts[:path] if opts[:path]
36
+ params[:sort_order] = opts[:sort_order] if opts[:sort_order] && (opts[:sort_order] == "asc" || opts[:sort_order] == "desc") # asc, desc
37
+ params[:count] = true if opts[:count] # When true, don't return the response's collection attribute.
38
+ params[:include_sub_pages] = true if opts[:include_sub_pages] # When true, include sub page form fields in the response
39
+
40
+ #Page params
41
+ params[:from] = opts[:from] if opts[:from] # Limit results to those created after from. Example: 2014-12-31T00:00:00.000Z
42
+ params[:to] = opts[:to] if opts[:to] # Limit results to those created before to. Example: 2014-12-31T23:59:59.999Z
43
+ params[:offset] = opts[:offset] if opts[:offset] # Omit the first offset number of results. Example: 3
44
+ params[:limit] = (opts[:limit] != nil && opts[:limit].to_i < MAX_RESULT_LIMIT.to_i && opts[:limit].to_i > 0 ) ? opts[:limit] : MAX_RESULT_LIMIT # Only return limit number of results. Example: 100
45
+ params[:with_stats] = opts[:with_stats] if opts[:with_stats] # When true, include page stats for the collection.
46
+ params[:role] = opts[:role] if opts[:role] # Restricts the scope of the returned pages. one of viewer, author
47
+
48
+ return params
49
+ end
50
+
51
+ def get_responses(opts = {})
52
+ params = set_params(opts)
53
+ response = parse_json(RestClient.get(@url+params[:path], params: params,Authorization: @auth, headers: @headers)).body
54
+
55
+ # response = (opts[:data]) ? response[opts[:data]] : response
56
+
57
+ return response
58
+ end
59
+
60
+ # Account
61
+ def get_accounts(opts = {})
62
+ opts[:path] = "/accounts"
63
+
64
+ if opts[:account_id]
65
+ opts[:path] = opts[:path] + "/#{opts[:account_id]}/pages"
66
+ else
67
+ # opts[:data] = "accounts"
68
+ end
69
+
70
+ return get_responses(opts)
71
+ end
72
+
73
+ # Pages
74
+ def get_pages(opts = {})
75
+ opts[:path] = "/pages"
76
+
77
+ if opts[:account_id]
78
+ opts[:path] = "/accounts/#{opts[:account_id]}/pages"
79
+ elsif opts[:page_id]
80
+ opts[:path] = opts[:path] + "/#{opts[:page_id]}"
81
+ opts[:path] = opts[:path] + "/form_fields" if opts[:form_fields] == true
82
+ else
83
+ # opts[:data] = "pages"
84
+ end
85
+
86
+ return get_responses(opts)
87
+ end
88
+
89
+ # Leads
90
+ def get_leads(opts = {})
91
+
92
+ if opts[:page_id]
93
+ opts[:path] = "/pages/#{opts[:page_id]}/leads"
94
+ # opts[:data] = "leads"
95
+ elsif opts[:lead_id]
96
+ opts[:path] = "/leads/#{opts[:lead_id]}"
97
+ end
98
+
99
+ return get_responses(opts)
100
+ end
101
+
102
+
103
+
104
+ end
105
+ end
@@ -0,0 +1,3 @@
1
+ module Unbounce
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "unbounce/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "unbounce"
8
+ spec.version = Unbounce::VERSION
9
+ spec.authors = ["Michael Hoskison"]
10
+ spec.email = ["mhoskison@etnainteractive.com"]
11
+
12
+ spec.summary = %q{Used to access the Unbounce api}
13
+ spec.description = %q{Unbounce API}
14
+ spec.homepage = "https://github.com/mhoskiso/unbounce.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+
37
+ spec.add_dependency "rest-client", "~> 2.0.2"
38
+ spec.add_dependency "json", "~> 2.1.0"
39
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unbounce
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Hoskison
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-29 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.1.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.1.0
83
+ description: Unbounce API
84
+ email:
85
+ - mhoskison@etnainteractive.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/unbounce.rb
101
+ - lib/unbounce/version.rb
102
+ - unbounce.gemspec
103
+ homepage: https://github.com/mhoskiso/unbounce.git
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ allowed_push_host: https://rubygems.org
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.6.8
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Used to access the Unbounce api
128
+ test_files: []