is24 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Bernd Suenkel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # is24
2
+
3
+ ## Overview
4
+
5
+ Simple Ruby Client for Immobilienscout24.
6
+
7
+ ### Installation
8
+
9
+ ```ruby
10
+ gem install is24
11
+ ```
12
+
13
+ ### Usage
14
+
15
+ ```ruby
16
+ # create client
17
+ client = Is24::Api.new(
18
+ token: YOUR_ACCESS_TOKEN,
19
+ secret: YOUR_TOKEN_SECRET,
20
+ consumer_key: YOUR_CONSUMER_KEY,
21
+ consumer_secret: YOUR_CONSUMER_SECRET
22
+ )
23
+ ```
24
+
25
+ Get expose for object
26
+
27
+ ```ruby
28
+ expose = client.expose(ID)
29
+
30
+ # complete expose
31
+ puts expose
32
+
33
+ # eg. address
34
+ puts expose.contactDetails.address
35
+ ```
36
+
37
+ ### Contributing to is24
38
+
39
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
40
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
41
+ * Fork the project.
42
+ * Start a feature/bugfix branch.
43
+ * Commit and push until you are happy with your contribution.
44
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
45
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
46
+
47
+ ## Copyright
48
+
49
+ Copyright (c) 2013 Bernd Suenkel. See LICENSE.txt for
50
+ further details.
File without changes
@@ -0,0 +1,70 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'faraday_middleware/response/mashify'
4
+
5
+ module Bnerd
6
+ class Api
7
+
8
+ def initialize( options = {} )
9
+ @secret = options[:secret] || nil
10
+ @api_key = options[:api_key] || nil
11
+ @public_key = options[:public_key] || nil
12
+ raise "Invalid Credentials" if @secret.nil? || @api_key.nil?
13
+ end
14
+
15
+ def videos
16
+ connection.get('videos').body
17
+ end
18
+
19
+ def video(id)
20
+ connection.get("videos/#{id}").body.video
21
+ end
22
+
23
+ def ingest
24
+ params = {
25
+ api_key: @api_key,
26
+ public_key: "f3bbb86e4d9b9a7a60e0b10ba0312535",
27
+ timestamp: 1360459978,
28
+ signature: '1325ea0ed234cbfceafcff19cc3732731da0d26af3a99f61f57195b271f190cc',
29
+ video: {
30
+ name: "foo",
31
+ description: "bar",
32
+ data: Faraday::UploadIO.new('/home/besu/Videos/second/178969.flv', 'video/mp4')
33
+ }
34
+ }
35
+ ingest_connection.post("/", params)
36
+ end
37
+
38
+ protected
39
+
40
+ def ingest_connection
41
+ Faraday::Connection.new(
42
+ :url => "https://ingest.bnerd.net:8043",
43
+ :ssl => { verify: false },
44
+ :headers => {
45
+ :user_agent => 'b\'nerd .video Ruby Client'}
46
+ ) do |builder|
47
+ builder.request :multipart
48
+ builder.request :url_encoded
49
+ builder.adapter Faraday.default_adapter
50
+ end
51
+ end
52
+
53
+ def connection
54
+ Faraday::Connection.new(
55
+ :url => "http://video.bnerd.net/api/v1",
56
+ :accept => 'application/json',
57
+ :params => {
58
+ auth_token: @secret,
59
+ api_key: @api_key
60
+ },
61
+ :headers => {
62
+ :accept => 'application/json',
63
+ :user_agent => 'b\'nerd .video Ruby Client'} ) do |builder|
64
+ builder.response :mashify
65
+ builder.response :json
66
+ builder.adapter Faraday.default_adapter
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,71 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'faraday_middleware/response/mashify'
4
+ require './bnerd/api/logger'
5
+
6
+ module Bnerd
7
+ class Api
8
+
9
+ def initialize( options = {} )
10
+ @secret = options[:secret] || nil
11
+ @api_key = options[:api_key] || nil
12
+ @public_key = options[:public_key] || nil
13
+ raise "Invalid Credentials" if @secret.nil? || @api_key.nil?
14
+ end
15
+
16
+ def videos
17
+ connection.get('videos').body
18
+ end
19
+
20
+ def video(id)
21
+ connection.get("videos/#{id}").body.video
22
+ end
23
+
24
+ def ingest
25
+ params = {
26
+ api_key: @api_key,
27
+ public_key: "f3bbb86e4d9b9a7a60e0b10ba0312535",
28
+ timestamp: 1360459978,
29
+ signature: '1325ea0ed234cbfceafcff19cc3732731da0d26af3a99f61f57195b271f190cc',
30
+ video: {
31
+ name: "foo",
32
+ description: "bar",
33
+ data: Faraday::UploadIO.new('/home/besu/Videos/second/178969.flv', 'video/mp4')
34
+ }
35
+ }
36
+ ingest_connection.post("/", params)
37
+ end
38
+
39
+ protected
40
+
41
+ def ingest_connection
42
+ Faraday::Connection.new(
43
+ :url => "https://ingest.bnerd.net:8043",
44
+ :ssl => { verify: false },
45
+ :headers => {
46
+ :user_agent => 'b\'nerd .video Ruby Client'}
47
+ ) do |builder|
48
+ builder.request :multipart
49
+ builder.request :url_encoded
50
+ builder.adapter Faraday.default_adapter
51
+ end
52
+ end
53
+
54
+ def connection
55
+ Faraday::Connection.new(
56
+ :url => "http://video.bnerd.net/api/v1",
57
+ :accept => 'application/json',
58
+ :params => {
59
+ auth_token: @secret,
60
+ api_key: @api_key
61
+ },
62
+ :headers => {
63
+ :accept => 'application/json',
64
+ :user_agent => 'b\'nerd .video Ruby Client'} ) do |builder|
65
+ builder.response :mashify
66
+ builder.response :json
67
+ builder.adapter Faraday.default_adapter
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,92 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'faraday_middleware/response/mashify'
4
+ require 'bnerd_video/logger'
5
+ require 'bnerd_video/model/video'
6
+
7
+ module BnerdVideo
8
+ class Api
9
+ include BnerdVideo::Logger
10
+
11
+ # PRODUCTION
12
+ API_ENDPOINT = "http://video.bnerd.net/api/v1"
13
+ INGEST_ENDPOINT = "https://ingest.bnerd.net:8043"
14
+
15
+ # DEVELOPMENT
16
+ API_ENDPOINT = "http://video.lvh.me:3000/api/v1"
17
+ INGEST_ENDPOINT = "https://ingest.bnerd.net:8043"
18
+
19
+ def initialize( options = {} )
20
+ logger "Initialized BnerdVideo with options #{options}"
21
+
22
+ @secret = options[:secret] || nil
23
+ @api_key = options[:api_key] || nil
24
+ @public_key = options[:public_key] || nil
25
+ raise "Invalid Credentials" if @secret.nil? || @api_key.nil?
26
+ end
27
+
28
+ def videos
29
+ response = connection.get('videos')
30
+ response.body.videos.map do |video|
31
+ BnerdVideo::Model::Video.new(video, self)
32
+ end
33
+ end
34
+
35
+ def video(id)
36
+ response = connection.get("videos/#{id}")
37
+ BnerdVideo::Model::Video.new(response.body, self)
38
+ end
39
+
40
+ def ingest(media, params)
41
+ ingest_connection.post("/", params)
42
+ end
43
+
44
+ def update(model)
45
+ response = connection.put("videos/#{model.id}") do |req|
46
+ req.headers['Content-Type'] = 'application/json'
47
+ req.body = model.to_json
48
+ end
49
+ BnerdVideo::Model::Video.new(response.body, self)
50
+ end
51
+
52
+ def destroy(model)
53
+ response = connection.delete("videos/#{model.id}") do |req|
54
+ req.headers['Content-Type'] = 'application/json'
55
+ req.body = model.to_json
56
+ end
57
+ BnerdVideo::Model::Video.new(response.body, self)
58
+ end
59
+
60
+ protected
61
+
62
+ def ingest_connection
63
+ Faraday::Connection.new(
64
+ :url => INGEST_ENDPOINT,
65
+ :ssl => { verify: false },
66
+ :headers => {
67
+ :user_agent => 'b\'nerd .video Ruby Client'}
68
+ ) do |builder|
69
+ builder.request :multipart
70
+ builder.request :url_encoded
71
+ builder.adapter Faraday.default_adapter
72
+ end
73
+ end
74
+
75
+ def connection
76
+ Faraday::Connection.new(
77
+ :url => API_ENDPOINT,
78
+ :accept => 'application/json',
79
+ :params => {
80
+ auth_token: @secret,
81
+ api_key: @api_key
82
+ },
83
+ :headers => {
84
+ :accept => 'application/json',
85
+ :user_agent => 'b\'nerd .video Ruby Client'} ) do |builder|
86
+ builder.response :mashify
87
+ builder.response :json
88
+ builder.adapter Faraday.default_adapter
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,62 @@
1
+ require 'is24/logger'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+ require 'faraday_middleware/response/mashify'
5
+
6
+ module Is24
7
+ class Api
8
+ include Is24::Logger
9
+
10
+ API_ENDPOINT = "http://rest.immobilienscout24.de/restapi/api/search/v1.0/"
11
+
12
+ def initialize( options = {} )
13
+ logger "Initialized Bnerd IS24 with options #{options}"
14
+
15
+ @token = options[:token] || nil
16
+ @secret = options[:secret] || nil
17
+ @consumer_secret = options[:consumer_secret] || nil
18
+ @consumer_key = options[:consumer_key] || nil
19
+
20
+ raise "Invalid Credentials" if @secret.nil? || @token.nil?
21
+ end
22
+
23
+ def search(options)
24
+ defaults = {
25
+ :channel => "hp",
26
+ :realestatetype => "housebuy",
27
+ :geocodes => 1276,
28
+ :username => "me"
29
+ }
30
+ options = defaults.merge(options)
31
+
32
+ response = connection.get("search/region", options )
33
+ response.body["resultlist.resultlist"]
34
+ end
35
+
36
+ def expose(id)
37
+ response = connection.get("expose/#{id}")
38
+ response.body["expose.expose"]
39
+ end
40
+
41
+ protected
42
+
43
+ def connection
44
+ Faraday::Connection.new(
45
+ :url => API_ENDPOINT,
46
+ :accept => 'application/json',
47
+ :headers => {
48
+ :accept => 'application/json',
49
+ :user_agent => 'b\'nerd .media IS24 Ruby Client'} ) do |builder|
50
+ builder.request :oauth, {
51
+ :consumer_key => @consumer_key,
52
+ :consumer_secret => @consumer_secret,
53
+ :token => @token,
54
+ :token_secret => @secret
55
+ }
56
+ builder.response :mashify
57
+ builder.response :json
58
+ builder.adapter Faraday.default_adapter
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ require 'is24/logger'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+ require 'faraday_middleware/response/mashify'
5
+
6
+ module Is24
7
+ class Api
8
+ include Is24::Logger
9
+
10
+ API_ENDPOINT = "http://rest.immobilienscout24.de/restapi/api/search/v1.0/"
11
+
12
+ def initialize( options = {} )
13
+ logger "Initialized Bnerd IS24 with options #{options}"
14
+
15
+ @token = options[:token] || nil
16
+ @secret = options[:secret] || nil
17
+ @consumer_secret = options[:consumer_secret] || nil
18
+ @consumer_key = options[:consumer_key] || nil
19
+
20
+ raise "Invalid Credentials" if @secret.nil? || @token.nil?
21
+ end
22
+
23
+ def search(options)
24
+ defaults = {
25
+ :channel => "hp",
26
+ :realestatetype => "housebuy",
27
+ :geocodes => 1276,
28
+ :username => "me"
29
+ }
30
+ options = defaults.merge(options)
31
+
32
+ response = connection.get("search/region", options )
33
+ response.body["resultlist.resultlist"]
34
+ end
35
+
36
+ def expose(id)
37
+ response = connection.get("expose/#{id}")
38
+ response.body["expose.expose"]
39
+ end
40
+
41
+ protected
42
+
43
+ def connection
44
+ Faraday::Connection.new(
45
+ :url => API_ENDPOINT,
46
+ :accept => 'application/json',
47
+ :headers => {
48
+ :accept => 'application/json',
49
+ :user_agent => 'b\'nerd .media IS24 Ruby Client'} ) do |builder|
50
+ builder.request :oauth, {
51
+ :consumer_key => @consumer_key,
52
+ :consumer_secret => @consumer_secret,
53
+ :token => @token,
54
+ :token_secret => @secret
55
+ }
56
+ builder.response :mashify
57
+ builder.response :json
58
+ builder.adapter Faraday.default_adapter
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,10 @@
1
+ module BnerdVideo
2
+ module Api
3
+ class Client
4
+ include BnerdVideo::Logger
5
+
6
+
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'logger'
2
+
3
+ module Is24
4
+ module Logger
5
+ def logger(msg)
6
+ @logger = ::Logger.new(STDOUT)
7
+ @logger.info msg
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'logger'
2
+
3
+ module Is24
4
+ module Logger
5
+ def logger(msg)
6
+ @logger = ::Logger.new(STDOUT)
7
+ @logger.info msg
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Is24
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,3 @@
1
+ module Is24
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: is24
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bernd Suenkel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: multi_json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hashie
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: faraday
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: faraday_middleware
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simple_oauth
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Simple Ruby API Client for Immobilienscout24.
95
+ email:
96
+ - bernd@bnerd.de
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - lib/is24.rb~
102
+ - lib/is24/version.rb
103
+ - lib/is24/logger.rb
104
+ - lib/is24/logger.rb~
105
+ - lib/is24/client.rb~
106
+ - lib/is24/version.rb~
107
+ - lib/bnerd-video.rb~
108
+ - lib/bnerd_video.rb~
109
+ - lib/bnerd.rb~
110
+ - lib/is24.rb
111
+ - LICENSE.txt
112
+ - Rakefile
113
+ - README.md
114
+ homepage: http://github.com/bnerd/is24
115
+ licenses: []
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 1.8.24
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Ruby API Client for Immobilienscout24.
138
+ test_files: []