eventbrite_contacts 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 59b1cf1ae83578e7798ba960a7cdb1c2731a6c16
4
+ data.tar.gz: 38ff07010221ee818fc17d08072f780f9415e012
5
+ SHA512:
6
+ metadata.gz: 95c9200659672676fce03e0c40d3c4575e39642a9c84c9dbb34442f8f8d424749360fc7d5f97a40ee1f1793927635bafd5a2bdf30e0f0d97582ad11295068dba
7
+ data.tar.gz: 03582c6420edca72328b0bc502424ebf46d6e9e0b032be8780d9dc5d578746ab2dcbdcca42f139da77d6b9a9eaa37962a0c40a1cc8f2d064547243a49124e1d9
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eventbrite_contacts.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # EventbriteContacts
2
+
3
+ Interact with the Eventbrite API to get, create and delete Contacts and Lists
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'eventbrite_contacts'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install eventbrite_contacts
20
+
21
+ ## Usage
22
+
23
+ The Eventbrie API authenticates a user using Oauth2 so an Oauth token must be
24
+ obtained. An Oauth stragey, such as the gem **omniauth-eventbrite** can be used to return
25
+ the Eventbrite Oauth token
26
+
27
+ Instantiate a client:
28
+
29
+ ```ruby
30
+ client = ::EventbriteContacts::Client.new("my_eventbrite_token", "my_eventbrite_user_id")
31
+ ```
32
+
33
+ Call the following methods on the client. options={} is an optional parameter in methods that
34
+ return a paginated response. If no argument is given the default page returned will be 1.
35
+ Supply the page in the following format:
36
+
37
+ ```ruby
38
+ {page: 3}
39
+ ```
40
+
41
+ To get a users contact lists
42
+
43
+ ```ruby
44
+ client.get_lists(options={})
45
+ ```
46
+
47
+ To get a specific list
48
+
49
+ ```ruby
50
+ client.get_list("my_list_id")
51
+ ```
52
+
53
+ To add a new list
54
+
55
+ ```ruby
56
+ client.add_list("my_new_list_name")
57
+ ```
58
+
59
+ To delete a list
60
+
61
+ ```ruby
62
+ client.delete_list("my_list_id")
63
+ ```
64
+
65
+ To return all the contacts in a list. The response is an array of hashes
66
+
67
+ ```ruby
68
+ client.get_all_contacts("my_list_id")
69
+ ```
70
+
71
+ To get a paginated response of contacts in a list
72
+
73
+ ```ruby
74
+ client.get_contacts("my_list_id", options={})
75
+ ```
76
+
77
+ To add a contact to a list
78
+
79
+ ```ruby
80
+ client.add_contact("my_list_id", contact)
81
+ ```
82
+
83
+ Where contact is a hash with the following attributes:
84
+
85
+ ```ruby
86
+ {
87
+ email: "eric@cantona.com",
88
+ first_name: "Eric",
89
+ last_name: "Cantona"
90
+ }
91
+ ```
92
+
93
+ To delete a contact
94
+
95
+ ```ruby
96
+ client.delete_contact("my_list_id", "eric@cantona.com")
97
+ ```
98
+
99
+ There is currently no option to update with the Eventbrite API. Their docs recommend to first
100
+ delete and then add a list or contact in order to update
101
+
102
+ For reference: https://www.eventbrite.com/developer/v3/quickstart/
103
+
104
+ ## Contributing
105
+
106
+ 1. Fork it ( https://github.com/cjlofts/eventbrite_contacts/fork )
107
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
108
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
109
+ 4. Push to the branch (`git push origin my-new-feature`)
110
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eventbrite_contacts"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eventbrite_contacts/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eventbrite_contacts"
8
+ spec.version = EventbriteContacts::Client::VERSION
9
+ spec.authors = ["Ciaran Lofts"]
10
+ spec.email = ["ciaran@wishpond.com"]
11
+ spec.description = %q{Create and remove Eventbrite contacts}
12
+
13
+ spec.summary = %q{Interact with the Eventbrite API to create Contact Lists and retrieve, create and delete Contacts}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ if spec.respond_to?(:metadata)
23
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
24
+ end
25
+
26
+ spec.add_dependency 'httparty'
27
+ spec.add_development_dependency "bundler", "~> 1.9"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency 'rspec'
30
+ end
@@ -0,0 +1,5 @@
1
+ module EventbriteContacts
2
+ class Client
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,104 @@
1
+ require 'eventbrite_contacts/version'
2
+ require 'httparty'
3
+
4
+ module EventbriteContacts
5
+ RateLimitExceeded = Class.new(StandardError)
6
+ class Client
7
+
8
+ BASE_URL = "https://www.eventbriteapi.com/v3/"
9
+
10
+ def initialize(auth_token, user_id)
11
+ @auth_token = auth_token
12
+ @user_id = user_id
13
+ end
14
+
15
+ def get_lists(options={})
16
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/?"
17
+ page = if options[:page].nil? then 1 else options[:page] end
18
+ encoded = URI.encode("#{url}page=#{page}")
19
+ response = make_request(encoded, "get")
20
+ raise_limit_error(response)
21
+ end
22
+
23
+ def get_list(list_id)
24
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/#{list_id}"
25
+ encoded = URI.encode(url)
26
+ response = make_request(encoded, "get")
27
+ raise_limit_error(response)
28
+ end
29
+
30
+ def add_list(list_name)
31
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/?"
32
+ encoded = URI.encode("#{url}contact_list.name=#{list_name}")
33
+ response = make_request(encoded, "post")
34
+ raise_limit_error(response)
35
+ end
36
+
37
+ def delete_list(list_id)
38
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/#{list_id}"
39
+ encoded = URI.encode(url)
40
+ response = make_request(encoded, "delete")
41
+ raise_limit_error(response)
42
+ end
43
+
44
+ def get_all_contacts(list_id)
45
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/#{list_id}/contacts"
46
+ page = 1
47
+ contacts = []
48
+ loop do
49
+ encoded = URI.encode("#{url}?page=#{page}")
50
+ response = make_request(encoded, "get")
51
+ raise_limit_error(response)
52
+ contacts << response["contacts"] unless response["contacts"].nil?
53
+ page += 1
54
+ break if response["error"] == "BAD_PAGE"
55
+ end
56
+ contacts.flatten
57
+ end
58
+
59
+ def get_contacts(list_id, options={})
60
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/#{list_id}/contacts?"
61
+ page = if options[:page].nil? then 1 else options[:page] end
62
+ encoded = URI.encode("#{url}page=#{page}")
63
+ response = make_request(encoded, "get")
64
+ raise_limit_error(response)
65
+ end
66
+
67
+ def add_contact(list_id, contact)
68
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/#{list_id}/contacts/?"
69
+ param_url = "contact.email=#{contact[:email]}&contact.first_name=#{contact[:first_name]}&contact.last_name=#{contact[:last_name]}"
70
+ encoded = URI.encode("#{url}#{param_url}")
71
+ response = make_request(encoded, "post")
72
+ raise_limit_error(response)
73
+ end
74
+
75
+ def delete_contact(list_id, contact_email)
76
+ url = "#{BASE_URL}users/#{@user_id}/contact_lists/#{list_id}/contacts/?"
77
+ encoded = URI.encode("#{url}email=#{contact_email}")
78
+ response = make_request(encoded, "delete")
79
+ raise_limit_error(response)
80
+ end
81
+
82
+ private
83
+
84
+ def make_request(url, verb)
85
+ case verb
86
+ when "get"
87
+ HTTParty.get(url, :headers => { "Authorization" => "Bearer #{@auth_token}" })
88
+ when "post"
89
+ HTTParty.post(url, :headers => { "Authorization" => "Bearer #{@auth_token}" })
90
+ when "delete"
91
+ HTTParty.delete(url, :headers => { "Authorization" => "Bearer #{@auth_token}" })
92
+ end
93
+ end
94
+
95
+ def raise_limit_error(response)
96
+ if response["error"] == "HIT_RATE_LIMIT"
97
+ raise RateLimitExceeded, "rate_limit_exceeded"
98
+ else
99
+ response
100
+ end
101
+ end
102
+
103
+ end
104
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eventbrite_contacts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ciaran Lofts
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Create and remove Eventbrite contacts
70
+ email:
71
+ - ciaran@wishpond.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - eventbrite_contacts.gemspec
86
+ - lib/eventbrite_contacts.rb
87
+ - lib/eventbrite_contacts/version.rb
88
+ homepage: ''
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ allowed_push_host: https://rubygems.org
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.6
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Interact with the Eventbrite API to create Contact Lists and retrieve, create
113
+ and delete Contacts
114
+ test_files: []