refreshingmenus_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -0
- data/lib/refreshingmenus_api.rb +4 -0
- data/lib/refreshingmenus_api/version.rb +1 -1
- data/lib/refreshingmenus_api/widget.rb +21 -0
- metadata +60 -52
data/README.md
CHANGED
@@ -24,6 +24,36 @@ Or install it yourself as:
|
|
24
24
|
result.first[:id] # => "194ebdcc-fcd9-11e1-b4ac-5254006b3bb5"
|
25
25
|
result.first[:menus].first[:title] # => "Pizzeria Kaart"
|
26
26
|
|
27
|
+
A query to match businesses / venues / places based on a phone number:
|
28
|
+
|
29
|
+
result = api.places(
|
30
|
+
:phone => '+31-(0)-10-2065151',
|
31
|
+
:country_code => 'NL'
|
32
|
+
)
|
33
|
+
result.first[:normalized_phone] # => "31102065151"
|
34
|
+
result.first[:id] # => "194e9016-fcd9-11e1-b4ac-5254006b3bb5"
|
35
|
+
|
36
|
+
This phone number is normalized based on the country_code passed. So '010-2065151' and '+31-(0)-10-2065151' with country_code 'NL' will be normalized to '31102065151'.
|
37
|
+
|
38
|
+
Because sometimes multiple places have the same phone number we can do more specific matching:
|
39
|
+
|
40
|
+
result = api.places(
|
41
|
+
:q => "#{place.name} #{place.postal_code}", # Matches at least one word.
|
42
|
+
:country_code => place.country_code, # Eg. 'NL'
|
43
|
+
:lat => place.lat,
|
44
|
+
:lng => place.lng,
|
45
|
+
:distance => '0.2', # 200 meter
|
46
|
+
:phone => place.phone_number # Eg. '010-12341234'.
|
47
|
+
)
|
48
|
+
|
49
|
+
## Widget usage
|
50
|
+
|
51
|
+
RefreshingmenusApi::Widget.tag(:place_id => 'some_place_id', :widget_token => 'some_token')
|
52
|
+
|
53
|
+
This will result in a script tag like:
|
54
|
+
|
55
|
+
<script id='rm-menuwidget' src='http://www.refreshingmenus.com/api/v1/widget.js?dom_id=rm-menuwidget&place_id=some_place_id&widget_token=some_token'></script>"
|
56
|
+
|
27
57
|
## Contributing
|
28
58
|
|
29
59
|
1. Fork it
|
data/lib/refreshingmenus_api.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'refreshingmenus_api/version'
|
2
|
+
require 'refreshingmenus_api/widget'
|
2
3
|
|
3
4
|
require 'httparty'
|
4
5
|
require 'active_support/core_ext'
|
@@ -28,6 +29,9 @@ module RefreshingmenusApi
|
|
28
29
|
|
29
30
|
attr_reader :auth_token, :version, :format
|
30
31
|
|
32
|
+
# Options:
|
33
|
+
# * :auth_token - Your RefreshingMenus Authentication token (API)
|
34
|
+
# * :version - Version (defaults to 1)
|
31
35
|
def initialize(options = {})
|
32
36
|
@auth_token = options[:auth_token]
|
33
37
|
@version = options[:version] || '1'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RefreshingmenusApi
|
2
|
+
class Widget
|
3
|
+
|
4
|
+
# Options:
|
5
|
+
# * widget_token (required) - Your RefreshingMenus Widget token
|
6
|
+
# * place_id (required) - The RefreshingMenus Place ID (UUID)
|
7
|
+
# * secure - Boolean, we'll use https if true
|
8
|
+
# * style - The style name we should use (default: 'default'), use 'none' for no styling (if you embed your own styling)
|
9
|
+
def self.tag(options)
|
10
|
+
raise ArgumentError, "Expected options argument to be a Hash, got #{options.inspect}." if not options.is_a?(Hash)
|
11
|
+
options[:dom_id] = 'rm-menuwidget'
|
12
|
+
raise ArgumentError, "Expected a :place_id as option but got #{options[:place_id].inspect}." if not options[:place_id].is_a?(String)
|
13
|
+
raise ArgumentError, "Expected a :widget_token as option but got #{options[:widget_token].inspect}." if not options[:widget_token].is_a?(String)
|
14
|
+
secure = options.delete(:secure)
|
15
|
+
version = options.delete(:version) || '1'
|
16
|
+
src = "#{secure ? 'https' : 'http'}://www.refreshingmenus.com/api/v#{version}/widget.js?#{options.to_param}"
|
17
|
+
return "<script id='#{options[:dom_id]}' src='#{src}'></script>"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: refreshingmenus_api
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Joost Hietbrink
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2012-09-17 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: httparty
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
name: activesupport
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
38
30
|
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: activesupport
|
39
34
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
46
44
|
description: Ruby API to use the Refreshing Menus REST API.
|
47
|
-
email:
|
45
|
+
email:
|
48
46
|
- joost@joopp.com
|
49
47
|
executables: []
|
48
|
+
|
50
49
|
extensions: []
|
50
|
+
|
51
51
|
extra_rdoc_files: []
|
52
|
-
|
52
|
+
|
53
|
+
files:
|
53
54
|
- .gitignore
|
54
55
|
- Gemfile
|
55
56
|
- LICENSE
|
@@ -57,30 +58,37 @@ files:
|
|
57
58
|
- Rakefile
|
58
59
|
- lib/refreshingmenus_api.rb
|
59
60
|
- lib/refreshingmenus_api/version.rb
|
61
|
+
- lib/refreshingmenus_api/widget.rb
|
60
62
|
- refreshingmenus_api.gemspec
|
63
|
+
has_rdoc: true
|
61
64
|
homepage: http://www.refreshingmenus.com
|
62
65
|
licenses: []
|
66
|
+
|
63
67
|
post_install_message:
|
64
68
|
rdoc_options: []
|
65
|
-
|
69
|
+
|
70
|
+
require_paths:
|
66
71
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
79
86
|
requirements: []
|
87
|
+
|
80
88
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
89
|
+
rubygems_version: 1.3.6
|
82
90
|
signing_key:
|
83
91
|
specification_version: 3
|
84
92
|
summary: Ruby API to use the Refreshing Menus REST API.
|
85
93
|
test_files: []
|
86
|
-
|
94
|
+
|