airbnb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fdf2e30410a692762c46563166da13d6e6cb854
4
- data.tar.gz: 3b0afcdc78969c9ffa1acc970848fae4aa4b74ec
3
+ metadata.gz: 762f80516b2878340eb1ded6c802f2bef58d3475
4
+ data.tar.gz: 991569f1aafd8959b48f01de2606d03f0b980f0a
5
5
  SHA512:
6
- metadata.gz: b9364762971745ee7b21856083f9819a2cb7be0b94d2e8f54f0f1feed7ebfbffc619935ea48244de495362238675996602d23a26d70cf7ea606f5d57a3db59ce
7
- data.tar.gz: 3261b8d3fa4d8d354ccc1868047e5c6fd6427e7c0debcb0cfc620c18c37262a3aa66c5283eeb07d58677cf8656a70c8df248cbbcc76b872ae32909d58754c871
6
+ metadata.gz: 8add642380ca41370474e9705977f4efeacff3a4ba188fc62ae63703e97c5c1b6872aed9164c0c2a19ddac5dd6bde2110d4bf1259e217596778ee963a22d7960
7
+ data.tar.gz: 07179527a71e2b416f8086bf7423758bcad97477fe98d5a187c8d0d000d6d1ba5a39f73af506c0f717ea2d1c125033c604da72482df60a874970d9961fb00fe2
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Airbnb
2
+ [![Gem Version](https://badge.fury.io/rb/airbnb.png)](http://badge.fury.io/rb/airbnb)
2
3
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/airbnb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
4
+ A Ruby interface to the Airbnb API.
5
+ Be careful, this gem is under development. Your pull requests are welcome!
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,13 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
25
+ TODO...
32
26
 
33
27
  ## Contributing
34
28
 
@@ -1,25 +1,25 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'airbnb/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "airbnb"
6
+ spec.add_dependency 'http', '~> 2.0'
7
+ spec.add_dependency 'mechanize', '~> 2.0'
8
+
9
+ spec.name = 'airbnb'
8
10
  spec.version = Airbnb::VERSION
9
- spec.authors = ["Kei Tsuchiya"]
10
- spec.email = ["kei.tsuchiya86@gmail.com"]
11
+ spec.authors = ['Kei Tsuchiya']
12
+ spec.email = ['kei.tsuchiya86@gmail.com']
11
13
 
12
- spec.summary = %q{A Ruby interface to the Airbnb.}
13
- spec.description = %q{A Ruby interface to the Airbnb.}
14
- spec.homepage = "https://github.com/kei500/airbnb"
15
- spec.license = "MIT"
14
+ spec.description = 'A Ruby interface to the Airbnb API.'
15
+ spec.summary = spec.description
16
+ spec.homepage = 'https://github.com/kei500/airbnb'
17
+ spec.license = 'MIT'
16
18
 
17
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
20
  f.match(%r{^(test|spec|features)/})
19
21
  end
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.13"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,5 +1,9 @@
1
- require "airbnb/version"
1
+ require 'airbnb/base'
2
+ require 'airbnb/v1'
3
+ require 'airbnb/v2'
4
+ require 'airbnb/v2/listings'
5
+ require 'airbnb/v2/users'
6
+ require 'airbnb/version'
2
7
 
3
8
  module Airbnb
4
- # Your code goes here...
5
9
  end
@@ -0,0 +1,28 @@
1
+ require 'http'
2
+ require 'mechanize'
3
+
4
+ module Airbnb
5
+ class Base
6
+ URL = 'https://api.airbnb.com'.freeze
7
+
8
+ class << self
9
+ def get(endpoint, params = {params: {}})
10
+ params[:params][:client_id] = client_id
11
+ HTTP.get(endpoint, params)
12
+ end
13
+
14
+ def post(endpoint, params)
15
+ params[:form][:client_id] = client_id
16
+ HTTP.post(endpoint, params)
17
+ end
18
+
19
+ private
20
+
21
+ def client_id
22
+ @@client_id ||= JSON.parse(
23
+ Mechanize.new.get("https://www.airbnb.com").search(:meta).select{|e| e['id'] == '_bootstrap-layout-init'}.first.get_attribute(:content)
24
+ )['api_config']['key']
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ require 'json'
2
+
3
+ module Airbnb
4
+ class V1 < Base
5
+ URL = "#{Airbnb::Base::URL}/v1".freeze
6
+
7
+ class << self
8
+ def authorize(params)
9
+ post("#{Airbnb::V1::URL}/authorize", form: params)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'json'
2
+
3
+ module Airbnb
4
+ class V2 < Base
5
+ URL = "#{Airbnb::Base::URL}/v2".freeze
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Airbnb
2
+ class V2::Listings < Base
3
+ class << self
4
+ def show(id)
5
+ get("#{Airbnb::V2::URL}/listings/#{id}", params: {_format: 'v1_legacy_for_p3'})
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Airbnb
2
+ class V2::Users < Base
3
+ class << self
4
+ def show(id)
5
+ get("#{Airbnb::V2::URL}/users/#{id}")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Airbnb
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbnb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kei Tsuchiya
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-25 00:00:00.000000000 Z
11
+ date: 2017-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mechanize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +80,7 @@ dependencies:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: '3.0'
55
- description: A Ruby interface to the Airbnb.
83
+ description: A Ruby interface to the Airbnb API.
56
84
  email:
57
85
  - kei.tsuchiya86@gmail.com
58
86
  executables: []
@@ -68,9 +96,12 @@ files:
68
96
  - README.md
69
97
  - Rakefile
70
98
  - airbnb.gemspec
71
- - bin/console
72
- - bin/setup
73
99
  - lib/airbnb.rb
100
+ - lib/airbnb/base.rb
101
+ - lib/airbnb/v1.rb
102
+ - lib/airbnb/v2.rb
103
+ - lib/airbnb/v2/listings.rb
104
+ - lib/airbnb/v2/users.rb
74
105
  - lib/airbnb/version.rb
75
106
  homepage: https://github.com/kei500/airbnb
76
107
  licenses:
@@ -95,5 +126,5 @@ rubyforge_project:
95
126
  rubygems_version: 2.5.1
96
127
  signing_key:
97
128
  specification_version: 4
98
- summary: A Ruby interface to the Airbnb.
129
+ summary: A Ruby interface to the Airbnb API.
99
130
  test_files: []
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "airbnb"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here