dealmap 0.0.2 → 0.0.3

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.
data/.gitignore CHANGED
@@ -4,4 +4,6 @@ Gemfile.lock
4
4
  pkg/*
5
5
  *.swp
6
6
  *.swo
7
- coverage
7
+ coverage
8
+ doc
9
+ .yardoc
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@dealmap
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ --protected
3
+ --markup markdown
4
+ -
data/README.md CHANGED
@@ -0,0 +1,46 @@
1
+ # Dealmap
2
+
3
+ Simple Ruby wrapper for the Dealmap [API](http://www.thedealmap.com/api/). [TheDealMap](http://thedealmap.com) features deals aggregated from a number of sources, includng Groupon, LivingSocial, Restaurants.com, and more.
4
+
5
+ ## Installation
6
+
7
+ sudo gem install dealmap
8
+
9
+ ## Usage
10
+
11
+ You'll need a Dealmap [API key](http://www.thedealmap.com/api/keys/).
12
+
13
+ require 'dealmap'
14
+ client = Dealmap::Client.new(YOUR_API_KEY)
15
+
16
+ ### Searching for deals in Brooklyn, NY
17
+ deals, total = client.search_deals(:l => "Brooklyn, NY")
18
+
19
+ ### Searching for deals based on lat/lng (Brooklyn, NY)
20
+ deals, total = client.search_deals(:l => "40.6500000, -73.9500000")
21
+
22
+ Dealmap uses a [`Hashie::Mash`](http://github.com/intridea/hashie) for return values, providing a handy hash that supports dot notation:
23
+
24
+ deals.first.title
25
+ => "$100 Gift Certificate, Your Price $40"
26
+ deals.first.city
27
+ => "Brooklyn"
28
+
29
+ <a name="changelog"></a>
30
+ ## Changelog
31
+
32
+ ### 0.0.3 - March 13, 2011
33
+
34
+ * Initial version
35
+
36
+ ## How to contribute
37
+
38
+ * Fork the project.
39
+ * Make your feature addition or bug fix.
40
+ * Add tests for it. This is important so I don't break it in a
41
+ future version unintentionally.
42
+ * Commit, do not mess with rakefile, version, or history.
43
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
44
+ * Send me a pull request. Bonus points for topic branches.
45
+
46
+ Copyright (c) 2011 [Josh Deeden](http://twitter.com/jdeeden).
data/dealmap.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency('vcr', '~> 1.7.0')
20
20
  s.add_development_dependency('fakeweb')
21
21
  s.add_development_dependency('yard', '~> 0.6')
22
+ s.add_development_dependency('maruku', '~> 0.6')
22
23
  s.add_runtime_dependency("faraday", '~> 0.5.7')
23
24
  s.add_runtime_dependency("typhoeus", '~> 0.2.4')
24
25
  s.add_runtime_dependency('nokogiri', '~> 1.4')
@@ -1,4 +1,6 @@
1
+ # Custom string extensions
1
2
  class String
3
+ # {http://www.urbandictionary.com/define.php?term=ganked Ganked} from ActiveSupport::Inflections. Works the same way it does in rails.
2
4
  def underscore
3
5
  word = self.to_s.dup
4
6
  word.gsub!(/::/, '/')
data/lib/dealmap.rb CHANGED
@@ -4,9 +4,13 @@ require "ext/string"
4
4
  require 'hashie/mash'
5
5
  require 'faraday'
6
6
 
7
+ # The Dealmap namespace.
7
8
  module Dealmap
9
+ # Defines methods for the Dealmap API
8
10
  class Client
9
11
  attr :api_key, :conn
12
+ # Initialize the Dealmap client
13
+ # @param api_key [String] Your Dealmap API Key
10
14
  def initialize(api_key)
11
15
  raise Dealmap::ApiKeyMissingError, "You must supply an API key" if api_key.nil?
12
16
  @api_key = api_key
@@ -16,6 +20,28 @@ module Dealmap
16
20
  end
17
21
  end
18
22
 
23
+ # Search for deals
24
+ # @param options [Hash] A customizable set of options
25
+ # @option options [String] :l Location around which the deals are searched for. This is a required field. This can be text value or lat/lon value. Examples: Seattle, WA or \+43.324-123.432. Note about geocoding: It is recommended that you send latitude/longitude location as it reduces the need for geo-coding (which may slow down your request) and may not be accurate at all times
26
+ # @option options [String] :q Query keyword. Optional. For example if you want to find beer deals, you send keyword as your query 'q=beer'. If you want to get all deals, either drop q or send q=\*
27
+ # @option options [Fixnum] :d Distance around the location specified in the query. Optional. Default value is 5 miles. Always expressed in miles.
28
+ # @option options [Fixnum] :si Start index of the deals. Used for paging through the results. Optional. Default value is 0 - which means start from the beginning.
29
+ # @option options [Fixnum] :ps Page size. Used for paging through the deal results. Optional. Default page size is 20. Maximum number of deals per page is 100.
30
+ # @option options [Fixnum] :a {http://apiwiki.thedealmap.com/index.php/Center%27d_Activity Center'd Activity}. Used to filter the results based on the type of activity. For example, send 1 for kid-friendly deals and 8 for romantic deals etc.
31
+ # @option options [String] :c {http://apiwiki.thedealmap.com/index.php/Deal_capability Deal capability}. Used to filter the results based on the deal type. For example, to get daily deals only, send c=16.
32
+ # @option options [String] :ed Expiration date. Used to filter the deals based on their expiration date. For example to get deals that are expiring soon (say by April 22nd 2010), you send ed=2010-04-22
33
+ # @return [Array, Fixnum] An array of Hashie::Mash objects representing deals. An integer representing the total number of deals available for retrieval. Note, this value and the size of the results array may differ, as *total* represents all available deals, not only the ones returned in your query.
34
+ #
35
+ # @example Search for deals in Miami, FL and get the total # of deals available
36
+ # @client = Dealmap::Client.new("YOUR_API_KEY")
37
+ # deals, total = @client.search_deals(:l => "Miami, FL")
38
+ # deals.each {|deal| puts deal.inspect }
39
+ # @example Search for all deals within a 50 mile radius of Miami, FL
40
+ # deals, total = @client.search_deals(:l => "Miami, FL", :d => 50)
41
+ # @example Search for beer deals within a 50 mile radius of Miami, FL
42
+ # deals, total = @client.search_deals(:l => "Miami, FL", :d => 50, :q => "beer")
43
+ # @example Search for beer deals within a 50 mile radius of Miami, FL and return 100 results
44
+ # deals, total = @client.search_deals(:l => "Miami, FL", :d => 50, :q => "beer", :ps => 100)
19
45
  def search_deals(options = {})
20
46
  options = options.merge(:key => api_key)
21
47
  response = conn.get("/search/deals/") { |req| req.params = options }
@@ -33,6 +59,27 @@ module Dealmap
33
59
  return deals, total
34
60
  end
35
61
 
62
+
63
+ # Search for businesses
64
+ # @param options [Hash] A customizable set of options
65
+ # @option options [String] :l Location around which the businesses are searched for. This is a required field. This can be text value or lat/lon value. Examples: Seattle, WA or \+43.324-123.432. Note about geocoding: It is recommended that you send latitude/longitude location as it reduces the need for geo-coding (which may slow down your request) and may not be accurate at all times
66
+ # @option options [String] :q Query keyword. Optional. For example if you want to find bars, you send keyword as your query 'q=bar'.
67
+ # @option options [Fixnum] :d Distance around the location specified in the query. Optional. Default value is 5 miles. Always expressed in miles.
68
+ # @option options [Fixnum] :si Start index of the businesses. Used for paging through the results. Optional. Default value is 0 - which means start from the beginning.
69
+ # @option options [Fixnum] :ps Page size. Used for paging through the business listing results. Optional. Default page size is 20. Maximum number of deals per page is 100.
70
+ # @option options [Fixnum] :a {http://apiwiki.thedealmap.com/index.php/Center%27d_Activity Center'd Activity}. Used to filter the results based on the type of activity. For example, send 1 for kid-friendly businesses and 8 for romantic businesses (whatever that means) etc.
71
+ # @return [Array, Fixnum] An array of Hashie::Mash objects representing businesses. An integer representing the total number of businesses available for retrieval. Note, this value and the size of the results array may differ, as *total* represents all available businesses, not only the ones returned in your query.
72
+ #
73
+ # @example Search for businesses in Miami, FL and get the total # of deals available
74
+ # @client = Dealmap::Client.new("YOUR_API_KEY")
75
+ # businesses, total = @client.search_businesses(:l => "Miami, FL")
76
+ # businesses.each {|business| puts business.inspect }
77
+ # @example Search for all businesses within a 50 mile radius of Miami, FL
78
+ # businesses, total = @client.search_businesses(:l => "Miami, FL", :d => 50)
79
+ # @example Search for bars within a 50 mile radius of Miami, FL
80
+ # businesses, total = @client.search_businesses(:l => "Miami, FL", :d => 50, :q => "bar")
81
+ # @example Search for bars within a 50 mile radius of Miami, FL and return 100 results
82
+ # businesses, total = @client.search_businesses(:l => "Miami, FL", :d => 50, :q => "bar", :ps => 100)
36
83
  def search_businesess(options = {})
37
84
  options = options.merge(:key => api_key)
38
85
  response = conn.get("/search/businesses/") { |req| req.params = options }
@@ -50,7 +97,57 @@ module Dealmap
50
97
  return businesses, total
51
98
  end
52
99
 
53
- def details(deal_id, options = {})
100
+ # Get deal details.
101
+ # @param deal_id [String] A deal id
102
+ # @param options [Hash] An optional set of options. Currently unused.
103
+ # @return [Hashie::Mash] A Hashie::Mash object representing a deal
104
+ # @example Example response:
105
+ # {"activity"=>"0",
106
+ # "added_by"=>"",
107
+ # "additional_discount_coupon_code"=>"",
108
+ # "additional_discount_coupon_effective_time"=>"0001-01-01T00:00:00",
109
+ # "additional_discount_coupon_expiration_time"=>"0001-01-01T00:00:00",
110
+ # "additional_discount_deal_unit"=>"0",
111
+ # "additional_discounted_value"=>"0",
112
+ # "address_line"=>"7726 W Sand Lake Rd",
113
+ # "affiliation"=>"",
114
+ # "b_description"=>"",
115
+ # "business_id"=>"",
116
+ # "business_name"=>"Shala Salon & Spa",
117
+ # "capability"=>"211",
118
+ # "category"=>"Beauty & Spas,Waxing",
119
+ # "city"=>"Orlando",
120
+ # "country"=>"",
121
+ # "currency"=>"1",
122
+ # "deal_source"=>"Groupon",
123
+ # "deal_type"=>"8",
124
+ # "deal_unit"=>"1",
125
+ # "description"=>"",
126
+ # "discounted_value"=>"10",
127
+ # "effective_time"=>"2011-03-13T03:01:00",
128
+ # "expiration_time"=>"2011-03-13T20:59:00",
129
+ # "face_value"=>"20",
130
+ # "id"=>"5-4A3EDD412F8C1ECF7F5A6AEDDAF7DA2A",
131
+ # "icon_url"=>"",
132
+ # "image_url"=>
133
+ # "http://www.groupon.com/images/site_images/0686/1969/Shala-Salon-_-Spa.jpg",
134
+ # "keywords"=>"",
135
+ # "latitude"=>"28.4498819801956",
136
+ # "longitude"=>"-81.4899128861725",
137
+ # "more_info_link"=>
138
+ # "http://www.thedealmap.com/deal/?dealid=5-4A3EDD412F8C1ECF7F5A6AEDDAF7DA2A&s=2-500726978-634341593775180000&utm_campaign=api",
139
+ # "phone"=>"",
140
+ # "state"=>"FL",
141
+ # "tags"=>"",
142
+ # "terms"=>"",
143
+ # "title"=>
144
+ # "$20 For A Full-Face Threading ($40 Value) Or $10 For An Eyebrow Threading ($20 Value) At Shala Salon & Day Spa",
145
+ # "tracking_url"=>"",
146
+ # "transaction_url"=>
147
+ # "http://www.thedealmap.com/x/?s=2-500726978-634341593775180000&id=5-4A3EDD412F8C1ECF7F5A6AEDDAF7DA2A",
148
+ # "you_save"=>"50 %",
149
+ # "zip_code"=>""}
150
+ def deal_details(deal_id, options = {})
54
151
  options = options.merge(:key => api_key)
55
152
  response = conn.get("/deals/#{deal_id}") { |req| req.params = options }
56
153
  doc = Nokogiri::XML(response.body)
@@ -1,3 +1,3 @@
1
1
  module Dealmap
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dealmap
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joshua Deeden
@@ -80,49 +80,60 @@ dependencies:
80
80
  type: :development
81
81
  version_requirements: *id006
82
82
  - !ruby/object:Gem::Dependency
83
- name: faraday
83
+ name: maruku
84
84
  prerelease: false
85
85
  requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "0.6"
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: faraday
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
86
97
  none: false
87
98
  requirements:
88
99
  - - ~>
89
100
  - !ruby/object:Gem::Version
90
101
  version: 0.5.7
91
102
  type: :runtime
92
- version_requirements: *id007
103
+ version_requirements: *id008
93
104
  - !ruby/object:Gem::Dependency
94
105
  name: typhoeus
95
106
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
107
+ requirement: &id009 !ruby/object:Gem::Requirement
97
108
  none: false
98
109
  requirements:
99
110
  - - ~>
100
111
  - !ruby/object:Gem::Version
101
112
  version: 0.2.4
102
113
  type: :runtime
103
- version_requirements: *id008
114
+ version_requirements: *id009
104
115
  - !ruby/object:Gem::Dependency
105
116
  name: nokogiri
106
117
  prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
118
+ requirement: &id010 !ruby/object:Gem::Requirement
108
119
  none: false
109
120
  requirements:
110
121
  - - ~>
111
122
  - !ruby/object:Gem::Version
112
123
  version: "1.4"
113
124
  type: :runtime
114
- version_requirements: *id009
125
+ version_requirements: *id010
115
126
  - !ruby/object:Gem::Dependency
116
127
  name: hashie
117
128
  prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
129
+ requirement: &id011 !ruby/object:Gem::Requirement
119
130
  none: false
120
131
  requirements:
121
132
  - - ~>
122
133
  - !ruby/object:Gem::Version
123
134
  version: 1.0.0
124
135
  type: :runtime
125
- version_requirements: *id010
136
+ version_requirements: *id011
126
137
  description: A very simple client for the DealMap API
127
138
  email:
128
139
  - jdeeden@gmail.com
@@ -134,13 +145,15 @@ extra_rdoc_files: []
134
145
 
135
146
  files:
136
147
  - .gitignore
148
+ - .rvmrc
149
+ - .yardopts
137
150
  - Gemfile
138
151
  - README.md
139
152
  - Rakefile
140
153
  - dealmap.gemspec
154
+ - lib/core_ext/string.rb
141
155
  - lib/dealmap.rb
142
156
  - lib/dealmap/version.rb
143
- - lib/ext/string.rb
144
157
  - spec/cassettes/Dealmap_Client/api/search_deals.yml
145
158
  - spec/client/client_spec.rb
146
159
  - spec/spec_helper.rb