barrio-client 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbe857759b27e4d4f841f2838b1d025586b6660e
4
+ data.tar.gz: 607d93bceac6b6e60302d57496feaed6d7c5af0c
5
+ SHA512:
6
+ metadata.gz: 41c6db3554d704c22d4b275eea4cfba7b0eecfcd8e870ffe11a8a7da93fcfdeb255982ace76829f48bd391ca74a8bac7fa140b9ebc0859ea02034e15400ec5f5
7
+ data.tar.gz: 0708e64b57a9e5d23edd80ade021e7de74a1bb49c7df465023cb91339fbe66599f4de387857bda4d8f9d58bd1a0f3845a169b232ebfbd1a688baa84da4f232d3
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in barrio-client.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Grupo Barrio, Inc.
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.
@@ -0,0 +1,94 @@
1
+ # Barrio Client
2
+
3
+ A ruby gem that makes it easy to access the [Barrio Platform API](http://www.barrio.mx/platform).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'barrio-client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install barrio-client
18
+
19
+ ## Usage
20
+
21
+ Wherever you want to request data, include the library and create an instance of the client:
22
+
23
+ ```ruby
24
+ require 'barrio-client'
25
+ client = Barrio::Client.new('your-client_id-here')
26
+ ```
27
+
28
+ You can get a client_id [here](http://www.barrio.mx/platform/client_id).
29
+
30
+ Then you can query for information:
31
+
32
+ ```ruby
33
+ locations = client.locations(:city => 'tijuana', :category => 'restaurant', :q => "kokopelli")
34
+
35
+ puts locations.count # Result: 2
36
+
37
+ puts locations.first.name # Result: Tacos Kokopelli
38
+ puts locations.first.location.address # Result: Ave. Ocampo entre la 8va y 9na, Tijuana, Baja California
39
+ puts locations.first.location.latitude # 32.524164
40
+ puts locations.first.location.longitude # -117.030916
41
+
42
+ locations.each do |l|
43
+ puts l.name
44
+ end
45
+
46
+ # Tacos Kokopelli
47
+ # Foodgarden
48
+ ```
49
+
50
+ ### Functionality
51
+
52
+ Four query methods are provided:
53
+
54
+ ```ruby
55
+ # Search for locations using any of the supported filters or criteria
56
+ locations = client.locations(:category => 'store', :city => 'ensenada')
57
+
58
+ # Query for one specific location by Barrio ID
59
+ location = client.location('barbacoa-el-corral-tijuana-mexico')
60
+
61
+ # Find all the pictures for a specific location
62
+ pictures = client.location_pictures('foodgarden-tijuana-mexico')
63
+ puts pictures.last.url.large # Result: https://www.filepicker.io/api/file/XRbqj4If...
64
+
65
+ # Look up one specific picture by id
66
+ picture = client.location_picture('foodgarden-tijuana-mexico', 1055)
67
+ ```
68
+
69
+ ### Supported Filters
70
+
71
+ When using `client.locations` to search, there are many supported filters you can use. They are all
72
+ [documented here](http://www.barrio.mx/platform/docs/2151829540.html).
73
+
74
+ Here are some examples:
75
+ * `:sort`
76
+ * Change the sort order of results
77
+ * `:q`
78
+ * Search for locations by keyword or text
79
+ * `:lat`/`:lng`
80
+ * Search for locations near a certain latitude/longitude coordinate
81
+ * `:category`
82
+ * Limit your search to one or more [categories](http://www.barrio.mx/platform/categories)
83
+ * `:city`
84
+ * Limit your search to one [city](http://www.barrio.mx/platform/categories)
85
+ * `:neighborhood`
86
+ * Limit your search to one [neighborhood](http://www.barrio.mx/platform/categories)
87
+
88
+ There are many more filters available. This library supports everything supported by the Barrio.mx Platform API,
89
+ so refer to the [API documentation](http://www.barrio.mx/platform/docs/2151829540.html) for a full list of available filters.
90
+
91
+ ### Help
92
+
93
+ If you need help or have questions, check out the [documentation](http://www.barrio.mx/platform)
94
+ or [contact us](http://www.barrio.mx/contact-us).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'barrio-client/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "barrio-client"
8
+ gem.version = Barrio::VERSION
9
+ gem.authors = ["Barrio.mx"]
10
+ gem.email = ["barrio@barrio.mx"]
11
+ gem.description = %q{Ruby client library for accessing the Barrio.mx Platform API.}
12
+ gem.summary = %q{See http://www.barrio.mx/platform for more information and documentation.}
13
+ gem.homepage = "http://www.barrio.mx/platform"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ #Dependencies
21
+ gem.add_dependency('rocket_pants', '~> 1.0')
22
+ end
@@ -0,0 +1,108 @@
1
+ require "barrio-client/version"
2
+ require 'rocket_pants'
3
+
4
+ module Barrio
5
+ class Client < RocketPants::Client
6
+
7
+ version 1
8
+ base_uri 'http://platform.barrio.mx/'
9
+
10
+ attr_accessor :client_id
11
+
12
+ def initialize(client_id)
13
+ @client_id = client_id
14
+ end
15
+
16
+ class City < APISmith::Smash
17
+ property :id
18
+ property :name
19
+ property :localized_name
20
+ end
21
+
22
+ class Neighborhood < APISmith::Smash
23
+ property :id
24
+ property :name
25
+ end
26
+
27
+ class PhysicalLocation < APISmith::Smash
28
+ property :city, :transformer => City
29
+ property :neighborhood, :transformer => Neighborhood
30
+ property :address
31
+ property :latitude
32
+ property :longitude
33
+ end
34
+
35
+ class LocationRating < APISmith::Smash
36
+ property :average_rating
37
+ property :weighted_rating
38
+ property :number_of_reviews
39
+ end
40
+
41
+ class ContactInfo < APISmith::Smash
42
+ property :website
43
+ property :phone
44
+ property :phone_formatted
45
+ end
46
+
47
+ class User < APISmith::Smash
48
+ property :id
49
+ property :url
50
+ property :name
51
+ end
52
+
53
+ class PictureSizes < APISmith::Smash
54
+ property :small
55
+ property :medium
56
+ property :large
57
+ end
58
+
59
+ class Picture < APISmith::Smash
60
+ property :id
61
+ property :description
62
+ property :user, :transformer => User
63
+ property :url, :transformer => PictureSizes
64
+ end
65
+
66
+ class PictureInformation < APISmith::Smash
67
+ property :has_pictures
68
+ property :main_picture, :transformer => Picture
69
+ end
70
+
71
+ class Category < APISmith::Smash
72
+ property :id
73
+ property :name
74
+ property :localized_name
75
+ property :parent, :transformer => Category
76
+ end
77
+
78
+ class Location < APISmith::Smash
79
+ property :id
80
+ property :name
81
+ property :rating, :transformer => LocationRating
82
+ property :categories, :transformer => Category
83
+ property :location, :transformer => PhysicalLocation
84
+ property :contact, :transformer => ContactInfo
85
+ property :pictures, :transformer => PictureInformation
86
+ property :features
87
+ property :hours
88
+ property :closed_permanently
89
+ end
90
+
91
+ def locations(options = {})
92
+ get 'locations', :transformer => Location, :extra_query => options.merge(:client_id => client_id)
93
+ end
94
+
95
+ def location(id, options = {})
96
+ get "locations/#{id}", :transformer => Location, :extra_query => options.merge(:client_id => client_id)
97
+ end
98
+
99
+ def location_pictures(location_id, options = {})
100
+ get "locations/#{location_id}/pictures", :transformer => Picture, :extra_query => options.merge(:client_id => client_id)
101
+ end
102
+
103
+ def location_picture(location_id, picture_id, options = {})
104
+ get "locations/#{location_id}/pictures/#{picture_id}", :transformer => Picture, :extra_query => options.merge(:client_id => client_id)
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,3 @@
1
+ module Barrio
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barrio-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Barrio.mx
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rocket_pants
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: Ruby client library for accessing the Barrio.mx Platform API.
28
+ email:
29
+ - barrio@barrio.mx
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - barrio-client.gemspec
40
+ - lib/barrio-client.rb
41
+ - lib/barrio-client/version.rb
42
+ homepage: http://www.barrio.mx/platform
43
+ licenses: []
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.0.6
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: See http://www.barrio.mx/platform for more information and documentation.
65
+ test_files: []