getevents 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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +96 -0
- data/Rakefile +7 -0
- data/getevents.gemspec +29 -0
- data/lib/getevents/client.rb +28 -0
- data/lib/getevents/event.rb +23 -0
- data/lib/getevents/fake_client.rb +14 -0
- data/lib/getevents/location.rb +20 -0
- data/lib/getevents/utils.rb +13 -0
- data/lib/getevents/version.rb +3 -0
- data/lib/getevents.rb +31 -0
- data/spec/fixtures/vcr/event_search.yml +4048 -0
- data/spec/fixtures/vcr/event_search_with_extra_params.yml +276 -0
- data/spec/fixtures/vcr/location_search.yml +70 -0
- data/spec/getevents/event_spec.rb +65 -0
- data/spec/getevents/location_spec.rb +36 -0
- data/spec/getevents_spec.rb +7 -0
- data/spec/spec_helper.rb +26 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4748e19810c3722b1e0a4ff5d532381dc0e83b8b
|
4
|
+
data.tar.gz: 1139cf6b0954654e0e176ea7c5398101c89eb6ef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38f67f1c1d1b4466274b5e9999fa28639debc908d3767a6f0fe8535a50975c09f5b09f42230f418a79f2950c4174805f4a58326ef49cf8b70a0b95620c12a863
|
7
|
+
data.tar.gz: e5cd125360ef636d404ceb04f57a26b01e6f7e032e6f3f8e8a5fb229031a102a9092547a445b889e78dfef265456d13472af437d1176ce95a71f7ae59c552bdd
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Loïc Delmaire
|
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,96 @@
|
|
1
|
+
# Getevents [](https://travis-ci.org/blackbirdco/getevents) [](https://codeclimate.com/repos/55ff1b0169568014780011e9/feed) [](https://codeclimate.com/repos/55ff1b0169568014780011e9/coverage)
|
2
|
+
|
3
|
+
API wrapper for [getevents.co](https://getevents.co/).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'getevents'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ gem install getevents
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### Initialisation
|
28
|
+
|
29
|
+
You need to signup in order to get credentials. Then, initialize your client:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Getevents.configure do |config|
|
33
|
+
config.account_id = GETEVENTS_ACCOUNT_ID
|
34
|
+
config.token = GETEVENTS_TOKEN
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
For testing purpose inside your application:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Getevents.configure do |config|
|
42
|
+
config.test_mode = true
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
It will render empty arrays for each methods.
|
47
|
+
|
48
|
+
### Location
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
locations = Getevents::Location.search('Paris')
|
52
|
+
location = locations.first
|
53
|
+
|
54
|
+
puts location.country
|
55
|
+
=> "France"
|
56
|
+
puts location.lng
|
57
|
+
=> -1.55336
|
58
|
+
```
|
59
|
+
|
60
|
+
### Event
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
events = Getevents::Event.search(47.21, -1.55, { start_date: "20150921" })
|
64
|
+
event = events.first
|
65
|
+
|
66
|
+
puts event.name
|
67
|
+
=> "La fête de la grenouille"
|
68
|
+
puts event.start_date
|
69
|
+
=> "2015-09-21T00:00:00.000Z"
|
70
|
+
```
|
71
|
+
|
72
|
+
### Eventlisting
|
73
|
+
|
74
|
+
TODO (not yet implemented)
|
75
|
+
|
76
|
+
### Eventlisting curate
|
77
|
+
|
78
|
+
TODO (not yet implemented)
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
1. Fork it ( https://github.com/blackbirdco/getevents/fork )
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create a new Pull Request
|
87
|
+
|
88
|
+
### Run tests
|
89
|
+
|
90
|
+
```sh
|
91
|
+
$ GETEVENTS_ACCOUNT_ID=YOUR_ACCOUNT_ID GETEVENTS_TOKEN=YOUR_TOKEN rspec spec/
|
92
|
+
```
|
93
|
+
|
94
|
+
## Links
|
95
|
+
|
96
|
+
* [API Documentation](https://dev.getevents.co/api-docs.html)
|
data/Rakefile
ADDED
data/getevents.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 'getevents/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "getevents"
|
8
|
+
spec.version = Getevents::VERSION
|
9
|
+
spec.authors = ["Loïc Delmaire"]
|
10
|
+
spec.email = ["loic.delmaire@gmail.com"]
|
11
|
+
spec.summary = %q{API wrapper for getevents.co}
|
12
|
+
spec.description = %q{API wrapper for getevents.co}
|
13
|
+
spec.homepage = "https://github.com/blackbirdco/getevents"
|
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_dependency "faraday"
|
22
|
+
spec.add_dependency "hashie"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "vcr"
|
27
|
+
spec.add_development_dependency "webmock"
|
28
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Getevents::Client
|
2
|
+
URL = "https://api.getevents.co"
|
3
|
+
|
4
|
+
attr_reader :connection
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
if test_mode?
|
8
|
+
@connection = Getevents::FakeClient.new
|
9
|
+
else
|
10
|
+
@connection = Faraday.new(url: URL) do |faraday|
|
11
|
+
faraday.headers["Authorization"] = "GetEvents #{account_id}:#{token}"
|
12
|
+
faraday.adapter Faraday.default_adapter
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def account_id
|
18
|
+
Getevents.configuration.account_id
|
19
|
+
end
|
20
|
+
|
21
|
+
def token
|
22
|
+
Getevents.configuration.token
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_mode?
|
26
|
+
Getevents.configuration.test_mode
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Getevents::Event
|
2
|
+
include Getevents::Utils
|
3
|
+
|
4
|
+
def self.search(lat, lng, params={})
|
5
|
+
new.search(lat, lng, params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def search(lat, lng, params={})
|
9
|
+
format_response_collection(raw_search(lat, lng, params), "events")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def raw_search(lat, lng, params)
|
15
|
+
connection.get do |req|
|
16
|
+
req.url '/event'
|
17
|
+
req.params = params.merge({
|
18
|
+
lat: lat,
|
19
|
+
lng: lng
|
20
|
+
})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Getevents::Location
|
2
|
+
include Getevents::Utils
|
3
|
+
|
4
|
+
def self.search(city)
|
5
|
+
new.search(city)
|
6
|
+
end
|
7
|
+
|
8
|
+
def search(city)
|
9
|
+
format_response_collection(raw_search(city), "cities")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def raw_search(city)
|
15
|
+
connection.get do |req|
|
16
|
+
req.url '/location'
|
17
|
+
req.params['city'] = city
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Getevents::Utils
|
2
|
+
protected
|
3
|
+
|
4
|
+
def format_response_collection(request, key)
|
5
|
+
JSON.parse(request.body)[key].map do |city_hash|
|
6
|
+
Hashie::Mash.new(city_hash)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def connection
|
11
|
+
@connection ||= Getevents::Client.new.connection
|
12
|
+
end
|
13
|
+
end
|
data/lib/getevents.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "json"
|
3
|
+
require "hashie/mash"
|
4
|
+
|
5
|
+
require "getevents/version"
|
6
|
+
require "getevents/utils"
|
7
|
+
require "getevents/client"
|
8
|
+
require "getevents/fake_client"
|
9
|
+
require "getevents/location"
|
10
|
+
require "getevents/event"
|
11
|
+
|
12
|
+
module Getevents
|
13
|
+
class << self
|
14
|
+
attr_accessor :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
self.configuration ||= Configuration.new
|
19
|
+
yield(configuration)
|
20
|
+
end
|
21
|
+
|
22
|
+
class Configuration
|
23
|
+
attr_accessor :test_mode, :account_id, :token
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@test_mode = false
|
27
|
+
@account_id = nil
|
28
|
+
@token = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|