eventioz 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 +25 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/lib/eventioz.rb +26 -0
- data/lib/eventioz/account.rb +12 -0
- data/lib/eventioz/auth.rb +35 -0
- data/lib/eventioz/event.rb +31 -0
- data/lib/eventioz/organizer.rb +29 -0
- data/lib/eventioz/registration.rb +31 -0
- data/lib/eventioz/version.rb +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d13e05f7487233359f89ebc917a99078d3a9c9f
|
4
|
+
data.tar.gz: 20f4206e4c84049ccbda38bfa26d67d888dd41ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f31ad58c9a5929167e8f90b410f89781066c7d1d5d46307d7881ecb3d0116b51add99d636f6a477e8e21b57e9669fe3528d9d3265dd72d39df2fe1ba9c32cbfc
|
7
|
+
data.tar.gz: 1564c11b71831201d7286804517cae37e392dd3cec5ba7a6170602bc2ef00927f58f52274c506db79d6c15cea62de1da79ba18df6691bf2c2db29efab7b2e44d
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
.idea
|
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
|
+
mkmf.log
|
24
|
+
.idea
|
25
|
+
*.gemspec
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Marlon Carvalho
|
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,51 @@
|
|
1
|
+
# Eventioz
|
2
|
+
|
3
|
+
It's a simple Ruby Wrapper to the Eventioz API. Eventioz is a Brazilian Ticket Platform used by many events in Brazil. This wrapper simplifies the use
|
4
|
+
of their API, providing a layer of abstraction. This is the first release and there're many improvements required. First off, we haven't done any tests
|
5
|
+
until now.
|
6
|
+
|
7
|
+
Feel free to send Pull Requests and ask for improvements. If you find any bug, fill an issue!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'eventioz'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install eventioz
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
First off, you have to log in to the Eventioz:
|
26
|
+
|
27
|
+
account = Eventioz.login(
|
28
|
+
:login => 'youremail@yourdomain.com',
|
29
|
+
:password => 'yourpassword')
|
30
|
+
|
31
|
+
Don't worry. This gem doesn't store your username and password in any way. It uses it only to sign in and get the API Key.
|
32
|
+
Once it has the API Key, it discards the username and password. Once you have the account data, you can access your organizers,
|
33
|
+
events and registrations. The next example shows how you can get all organizers.
|
34
|
+
|
35
|
+
Eventioz::Organizer.all(api_key)
|
36
|
+
|
37
|
+
To get all events that belong to an Organizer:
|
38
|
+
|
39
|
+
Eventioz::Event.all(api_key, organizer.cached_slug)
|
40
|
+
|
41
|
+
To get all registrations from an event:
|
42
|
+
|
43
|
+
Eventioz::Registration.all(api_key, event.cached_slug)
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/marloncarvalho/eventioz/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/eventioz.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'eventioz/account'
|
5
|
+
require 'eventioz/version'
|
6
|
+
require 'eventioz/auth'
|
7
|
+
require 'eventioz/organizer'
|
8
|
+
require 'eventioz/event'
|
9
|
+
require 'eventioz/registration'
|
10
|
+
|
11
|
+
|
12
|
+
# A Ruby client library for the Eventioz platform.
|
13
|
+
# See http://github.com/marloncarvalho/eventioz for a general introduction.
|
14
|
+
module Eventioz
|
15
|
+
BASE_URL = 'https://eventioz.com.br/'
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
def login(params = {})
|
20
|
+
map = Eventioz::Auth.authorize(params)
|
21
|
+
Eventioz::Account.new(:email => map['account']['email'], :api_key => map['account']['api_key'])
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Eventioz
|
2
|
+
|
3
|
+
# Used to authenticate against the Eventioz API and get the API Key.
|
4
|
+
#
|
5
|
+
# The Login and Password aren't stored localy. They're used only to authenticate
|
6
|
+
# Afterwards they're discarded.
|
7
|
+
#
|
8
|
+
# Every API call must have an API Key appended to it and an instance of this class
|
9
|
+
# is responsible to get this key.
|
10
|
+
class Auth
|
11
|
+
|
12
|
+
# Calls the Eventioz API asking for the API Key.
|
13
|
+
#
|
14
|
+
# Arguments:
|
15
|
+
# config: (Hash)
|
16
|
+
def self.authorize(config = {:login => nil, :password => nil, :locale => 'pt'})
|
17
|
+
validate_config config
|
18
|
+
|
19
|
+
json = JSON.parse RestClient.post("#{Eventioz::BASE_URL}session.json?login=#{config[:login]}&password=#{config[:password]}&local=#{config[:locale]}", nil, nil)
|
20
|
+
raise 'Unauthorized' unless json['errors'].nil?
|
21
|
+
json
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Just validates if the config object contains all required data.
|
27
|
+
def self.validate_config(config)
|
28
|
+
raise 'Config cannot be null' if config.nil?
|
29
|
+
raise 'User cannot be null' if config[:login].nil?
|
30
|
+
raise 'Password cannot be null' if config[:password].nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module Eventioz
|
3
|
+
|
4
|
+
# Represents an Eventioz Event.
|
5
|
+
class Event
|
6
|
+
attr_accessor :cached_slug, :name, :registrations_count, :start_date, :end_date, :time_zone, :created_at, :status, :api_key
|
7
|
+
|
8
|
+
def initialize(h = {})
|
9
|
+
h.each { |key, value| send("#{key}=", value) }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns all events created by a specific organizer.
|
13
|
+
def self.all(api_key, organizer_slug)
|
14
|
+
result = []
|
15
|
+
|
16
|
+
json = JSON.parse RestClient.get("#{BASE_URL}admin/organizers/#{organizer_slug}/events.json?api_key=#{api_key}")
|
17
|
+
json.each do |event|
|
18
|
+
e = Eventioz::Event.new({})
|
19
|
+
event['event'].each do |key, value|
|
20
|
+
e.send("#{key}=", value)
|
21
|
+
end
|
22
|
+
e.api_key = @api_key
|
23
|
+
result << e
|
24
|
+
end
|
25
|
+
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eventioz
|
2
|
+
|
3
|
+
# Represents an Eventioz Organizer.
|
4
|
+
class Organizer
|
5
|
+
attr_accessor :cached_slug, :locale, :name, :api_key
|
6
|
+
|
7
|
+
def initialize(h = {})
|
8
|
+
h.each { |key, value| send("#{key}=", value) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.all(api_key)
|
12
|
+
result = []
|
13
|
+
|
14
|
+
json = JSON.parse RestClient.get("#{BASE_URL}admin/account.json?api_key=#{api_key}")
|
15
|
+
json.each do |org|
|
16
|
+
o = Eventioz::Organizer.new({})
|
17
|
+
org['organizer'].each do |key, value|
|
18
|
+
o.send("#{key}=", value)
|
19
|
+
end
|
20
|
+
o.api_key = @api_key
|
21
|
+
result << o
|
22
|
+
end
|
23
|
+
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Eventioz
|
2
|
+
|
3
|
+
# Represents an Eventioz Registration.
|
4
|
+
class Registration
|
5
|
+
attr_accessor :accreditation_code, :attended, :cancelled_at, :created_at, :email,
|
6
|
+
:first_name, :last_name, :purchased_at, :random_code,
|
7
|
+
:amount, :due_date, :second_amount, :second_due_date
|
8
|
+
|
9
|
+
def initialize(h = {})
|
10
|
+
h.each { |key, value| send("#{key}=", value) }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Calls the Eventioz API to retrieve all tickets purchased to a specific event.
|
14
|
+
def self.all(api_key, event_slug)
|
15
|
+
result = []
|
16
|
+
|
17
|
+
json = JSON.parse RestClient.get("#{BASE_URL}admin/events/#{event_slug}/registrations.json?api_key=#{api_key}")
|
18
|
+
json.each do |reg|
|
19
|
+
r = Eventioz::Registration.new({})
|
20
|
+
reg['registration'].each do |key, value|
|
21
|
+
r.send("#{key}=", value)
|
22
|
+
end
|
23
|
+
result << r
|
24
|
+
end
|
25
|
+
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eventioz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marlon Silva Carvalho
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-03 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
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: A Ruby client library for the Eventioz platform.
|
42
|
+
email:
|
43
|
+
- marlon.carvalho@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- eventioz.gemspec
|
54
|
+
- lib/eventioz.rb
|
55
|
+
- lib/eventioz/account.rb
|
56
|
+
- lib/eventioz/auth.rb
|
57
|
+
- lib/eventioz/event.rb
|
58
|
+
- lib/eventioz/organizer.rb
|
59
|
+
- lib/eventioz/registration.rb
|
60
|
+
- lib/eventioz/version.rb
|
61
|
+
homepage: http://github.com/marloncarvalho/eventioz
|
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.2.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: A Ruby client library for the Eventioz platform.
|
85
|
+
test_files: []
|