expedia_api 0.1.0 → 0.1.1

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: ee2e06abd36c267bf1ab2d0a340886915496ba49
4
- data.tar.gz: 927f042a6792ad89c34532cfd9f7c2fa11227761
3
+ metadata.gz: b775cb669fbc7e21933c827b2f576308510b20fe
4
+ data.tar.gz: 031b9e06e2b77ae18e583a50d7c0ad1371fbb99b
5
5
  SHA512:
6
- metadata.gz: e0e857fe39eba7e119030defacb813f96cda740c22f726108a2324293919531b7b1111c28a9943b799f7d98cf06a0193ebce4a4b13aa75a3c05749c3c213a5f8
7
- data.tar.gz: f3e64a4040786905376f2453aa41c4d1037e3d83138061a6f8fff92ce8bf6d749901541a4dbd40429a444c8651a95b64c830fb7e9eef2fea55c7c0cefebd8eaf
6
+ metadata.gz: a905024f1fe7eb4acc520ac59283037017122e7f1b5e4b957ade361207af61c6df969ddc416481d1db861dd1143a76ddc81cb69119542a1dfbda08c5e0261903
7
+ data.tar.gz: ade3c780ba67e6465e94c39686fc4d0b4c82776baad4fd44afb973c5b01fb94d3e2b6f41b3673ea40cf5221b679b79c087c5a7a1391a2c45c9a4fe06a76e2aab
@@ -7,6 +7,8 @@ require "expedia_api/version"
7
7
  require "expedia_api/http_service"
8
8
  require "expedia_api/client"
9
9
  require "expedia_api/hotel_response_list"
10
+ require "expedia_api/entities"
11
+ require "expedia_api/entities/search_entity"
10
12
 
11
13
  module ExpediaApi
12
14
  class << self
@@ -0,0 +1,4 @@
1
+ module ExpediaApi
2
+ module Entities
3
+ end
4
+ end
@@ -0,0 +1,71 @@
1
+ module ExpediaApi
2
+ module Entities
3
+ class SearchEntity
4
+ attr_reader :raw_data
5
+
6
+ def initialize(raw_data)
7
+ @raw_data = raw_data
8
+ end
9
+
10
+ def available?
11
+ !!raw_data[:Price].fetch(:TotalRate, nil)
12
+ end
13
+
14
+ def sold_out?
15
+ !available?
16
+ end
17
+
18
+ def total_price_including_taxes
19
+ if available?
20
+ raw_data[:Price][:TotalRate][:Value].to_f
21
+ else
22
+ nil
23
+ end
24
+ end
25
+
26
+ def currency
27
+ if available?
28
+ raw_data[:Price][:TotalRate][:Currency]
29
+ else
30
+ nil
31
+ end
32
+ end
33
+
34
+ def id
35
+ raw_data[:HotelID].to_i
36
+ end
37
+
38
+ def expedia_id
39
+ id
40
+ end
41
+
42
+ def has_promotion?
43
+ !!raw_data[:Promotion].fetch(:Amount, nil)
44
+ end
45
+
46
+ def promotion_text
47
+ if has_promotion?
48
+ raw_data[:Promotion][:Description]
49
+ else
50
+ nil
51
+ end
52
+ end
53
+
54
+ def promotion_value
55
+ if has_promotion?
56
+ raw_data[:Promotion][:Amount][:Value].to_f
57
+ else
58
+ nil
59
+ end
60
+ end
61
+
62
+ def promotion_currency
63
+ if has_promotion?
64
+ raw_data[:Promotion][:Amount][:Currency]
65
+ else
66
+ nil
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -22,7 +22,7 @@ module ExpediaApi
22
22
  end
23
23
 
24
24
  def entries=(entries)
25
- @entries = entries.map {|e| e.with_indifferent_access }
25
+ @entries = entries.map {|e| ExpediaApi::Entities::SearchEntity.new(e.with_indifferent_access) }
26
26
  end
27
27
 
28
28
  def success?
@@ -1,3 +1,3 @@
1
1
  module ExpediaApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expedia_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Kleinwaechter
@@ -141,6 +141,8 @@ files:
141
141
  - expedia_api.gemspec
142
142
  - lib/expedia_api.rb
143
143
  - lib/expedia_api/client.rb
144
+ - lib/expedia_api/entities.rb
145
+ - lib/expedia_api/entities/search_entity.rb
144
146
  - lib/expedia_api/hotel_response_list.rb
145
147
  - lib/expedia_api/http_service.rb
146
148
  - lib/expedia_api/version.rb