event_finda_ruby 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/lib/event_finda_ruby/base.rb +34 -0
- data/lib/event_finda_ruby/events.rb +98 -0
- data/lib/event_finda_ruby/version.rb +3 -0
- data/lib/event_finda_ruby.rb +3 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 121285bdfe914114662e7433df52a2ac757a1810
|
4
|
+
data.tar.gz: ab8ca7df8ce4761c97a1b2616873c3282128e82b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 950df5606005364f01aa73606e8d4165ff7d8d006dfd249c53c12d1391d3d9f7c2863139e4f8da37db96701e4ecee3941f4d75fa8910724ed58351227767d063
|
7
|
+
data.tar.gz: 03390032d42f71c0ecff940502071060bee3a5cfd76248e56a9f02fb7cb87b587055f94b385050482ed078caf54ffa2dd53641a3641e5c7c59ddaca1b437af31
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
class Base
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
BASE_URL = "http://api.eventfinda.co.nz/v2/events".freeze
|
7
|
+
|
8
|
+
attr_reader :api_extension
|
9
|
+
attr_reader :auth
|
10
|
+
attr_reader :url
|
11
|
+
|
12
|
+
def initialize(auth)
|
13
|
+
@api_extension = "json"
|
14
|
+
@auth = auth
|
15
|
+
@url = base_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def with_extension(extension)
|
19
|
+
if ["json", "xml"].include? extension
|
20
|
+
@api_extension = extension
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# retrieving maximum set of results by default: 20
|
27
|
+
def base_path
|
28
|
+
"#{BASE_URL}.#{api_extension}?rows=20"
|
29
|
+
end
|
30
|
+
|
31
|
+
def apply_filter(filter_name, value)
|
32
|
+
@url = "#{url}&#{filter_name}=#{value}"
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module EventFindaRuby
|
2
|
+
class Events < Base
|
3
|
+
|
4
|
+
BASE_URL = "http://api.eventfinda.co.nz/v2/events".freeze
|
5
|
+
|
6
|
+
def by_end_date(end_date)
|
7
|
+
apply_filter "end_date", end_date
|
8
|
+
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def by_featured
|
13
|
+
apply_filter "featured", 1
|
14
|
+
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def by_free
|
19
|
+
apply_filter "free", 1
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def by_keywords_and(keywords)
|
25
|
+
apply_filter "q", set_keywords_and(keywords)
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def by_keywords_or(keywords)
|
31
|
+
apply_filter "q", set_keywords_or(keywords)
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# allowing AND/OR behavior customized by developer
|
37
|
+
# /events.xml?q=(cycling+AND+running+AND+swimming)+OR+triathlon
|
38
|
+
def by_query(query)
|
39
|
+
apply_filter "q", query
|
40
|
+
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def by_rows(rows)
|
45
|
+
apply_filter "rows", rows
|
46
|
+
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# price_max format "35.0" or "35"
|
51
|
+
def by_price_max(price_max)
|
52
|
+
apply_filter "price_max", price_max
|
53
|
+
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
# price_min format "35.0" or "35"
|
58
|
+
def by_price_min(price_min)
|
59
|
+
apply_filter "price_min", price_min
|
60
|
+
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
def by_start_date(start_date)
|
65
|
+
apply_filter "start_date", start_date
|
66
|
+
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
def by_ticketed
|
71
|
+
apply_filter "ticketed", 1
|
72
|
+
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
def by_username(username)
|
77
|
+
apply_filter "username", username
|
78
|
+
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
def results
|
83
|
+
response = HTTParty.get("#{url}", basic_auth: auth)
|
84
|
+
|
85
|
+
@results = response["events"]
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def set_keywords_or(keywords)
|
91
|
+
keywords.to_a.join("+OR+")
|
92
|
+
end
|
93
|
+
|
94
|
+
def set_keywords_and(keywords)
|
95
|
+
keywords.to_a.join("+AND+")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: event_finda_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Roldan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-05 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.13.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.7
|
27
|
+
description: 'Ruby client to interact with Eventfinda API: www.eventfinda.co.nz'
|
28
|
+
email: juanroldan1989@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/event_finda_ruby.rb
|
34
|
+
- lib/event_finda_ruby/base.rb
|
35
|
+
- lib/event_finda_ruby/events.rb
|
36
|
+
- lib/event_finda_ruby/version.rb
|
37
|
+
homepage: http://rubygems.org/gems/event_finda_ruby
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.2.2
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Eventfinda Ruby
|
61
|
+
test_files: []
|