RDC 0.1.1 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 296ad5ee8fdf75da3cc8dab3640dcccbe04f16a7fa5c465253666db9ddabd43d
4
- data.tar.gz: 3218e90fca0a4d9db1523f173fe798216ac4c8de5bad9ee573e1c6fde2d93ce2
3
+ metadata.gz: 3b7225346ddce7d0a46693e8553b857081608f0de2611afc053f8bec47fce380
4
+ data.tar.gz: ce6f0b9a0b595a63464c5c85af73af1da20c573180a6b499b515f72483c329cc
5
5
  SHA512:
6
- metadata.gz: d6f7af05ca5a4d6f19688470da2d4c86f8ab6923f37ff2aa471c68d5b4362cace877a9c78080141921b868bec990a45eba8b151263cc0782342b6f79775ac6cd
7
- data.tar.gz: '028971bffed27b3689fd5eb1e64f986a4dc40cb5391d7c6d10067d1e8eb1643863a21e813132e3a82ed028605f0dcb13312dfa061523d8e6593a571e33506250'
6
+ metadata.gz: 8da84d35c4edf3ac85b826a2435ae21eea4d5532a46c1b7e78823f9ef3da7168e43712bda7d582c97e0e8d7aa95c98136b6fe8b8988381d0b66c373d155bb2f5
7
+ data.tar.gz: 7adf4760a2695daf2bab8b7553cd98b74ee85b520bfe89ea19114ebf167a8bf13b2cff8f41186f4c8a9df5d3b9ba567348d4048b36033745826dbbe0670e4553
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RDC (0.1.0)
5
- activesupport (= 5.2.3)
4
+ RDC (0.1.5)
5
+ activesupport
6
6
  net-sftp (= 3.0.0)
7
- rubyzip (= 2.3.0)
7
+ rubyzip
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -89,4 +89,4 @@ DEPENDENCIES
89
89
  webmock
90
90
 
91
91
  BUNDLED WITH
92
- 2.1.2
92
+ 2.1.4
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
30
 
31
- spec.add_dependency 'activesupport', '5.2.3'
31
+ spec.add_dependency 'activesupport'
32
32
  spec.add_dependency 'net-sftp', '3.0.0'
33
33
  spec.add_dependency 'rubyzip'
34
34
  end
data/lib/RDC.rb CHANGED
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "RDC/version"
2
4
  require "RDC/catalog"
3
- require "RDC/restaurant_info"
5
+ require "RDC/order"
6
+ require "RDC/sku"
7
+ require "RDC/cart"
4
8
 
5
9
  module RDC
6
10
  class Error < StandardError; end
@@ -8,6 +12,7 @@ module RDC
8
12
  class << self
9
13
  attr_accessor :api_key, :environment
10
14
  attr_accessor :ftp_username, :ftp_password, :ftp_url
15
+ attr_accessor :prti
11
16
 
12
17
  def root
13
18
  File.dirname __dir__
@@ -5,9 +5,9 @@ require 'RDC/request'
5
5
  module RDC
6
6
  class Cart
7
7
  class << self
8
- def create(sku_id)
9
- request = Request.new("/validate_sku?sku=#{sku_id}")
10
- reponse = request.get
8
+ def create(params)
9
+ request = Request.new("/create_shopping_cart_id")
10
+ reponse = request.get(params)
11
11
  response.json
12
12
  end
13
13
  end
@@ -43,7 +43,11 @@ module RDC
43
43
  private
44
44
 
45
45
  def downloads_directory
46
- @downloads_directory ||= Pathname.new(RDC.root).join('downloads')
46
+ @downloads_directory ||= begin
47
+ directory = Pathname.new(RDC.root).join('downloads')
48
+ FileUtils.mkdir_p directory
49
+ directory
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -2,16 +2,17 @@
2
2
 
3
3
  module RDC
4
4
  class Item
5
- attr_accessor :sku, :legacy_sku, :value, :price, :restriction, :restriction_detail
5
+ attr_accessor :sku, :legacy_sku, :value, :price, :restriction, :restriction_detail,
6
+ :available_inventory
6
7
 
7
8
  def initialize(hash_values)
8
- puts "Hash Values :: #{hash_values}"
9
9
  @sku = hash_values['ProductSKU']
10
10
  @legacy_sku = hash_values['LegacyProductSKU']
11
11
  @value = hash_values['ItemValue']
12
12
  @price = hash_values['ItemPrice']
13
13
  @restriction = hash_values['ItemRestriction']
14
14
  @restriction_detail = hash_values['ItemRestrictionDetail']
15
+ @available_inventory = hash_values['ItemAvailableInventory']
15
16
  end
16
17
  end
17
18
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'request'
4
+
5
+ module RDC
6
+ class Order
7
+ class << self
8
+ def process_order_body(params = {})
9
+ request = Request.new("/process_order_body")
10
+ response = request.post(params.merge(prti_params(params)))
11
+ response.json
12
+ end
13
+
14
+ private
15
+
16
+ def prti_params(params)
17
+ {
18
+ prti: RDC.prti,
19
+ partneradid: RDC.prti
20
+ }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -12,9 +12,9 @@ module RDC
12
12
 
13
13
  def base_url
14
14
  if RDC.environment == 'production'
15
- 'http://connect.restaurant.com/api'
15
+ 'http://connect.restaurant.com/api'.freeze
16
16
  else
17
- 'https://dev-connect.restaurant.com/api'
17
+ 'https://dev-connect.restaurant.com/api'.freeze
18
18
  end
19
19
  end
20
20
 
@@ -25,6 +25,13 @@ module RDC
25
25
  self
26
26
  end
27
27
 
28
+ def post(params = {})
29
+ self.response = HTTP.headers(headers)
30
+ .post(url, { json: params })
31
+ self.json = JSON.parse(response.body.to_s, symbolize_names: true)
32
+ self
33
+ end
34
+
28
35
  def url
29
36
  "#{base_url}#{path}"
30
37
  end
@@ -5,7 +5,8 @@ require_relative 'item'
5
5
  module RDC
6
6
  class Restaurant
7
7
  attr_accessor :name, :items, :short_description, :long_description,
8
- :online, :address, :image, :id
8
+ :online, :address, :image, :id, :communication_media,
9
+ :recommended_rank, :rating, :cuisines, :additional_attributes
9
10
 
10
11
  def initialize(hash_values)
11
12
  @id = hash_values['LegacyRestaurantId']
@@ -13,8 +14,13 @@ module RDC
13
14
  @short_description = hash_values['ShortDescription']
14
15
  @long_description = hash_values['LongDescription']
15
16
  @online = hash_values['OnlineReservation']
17
+ @recommended_rank = hash_values['RecommendedRank']
18
+ @rating = hash_values['Rating']
19
+ @cuisines = hash_values['Cuisine']
20
+ @additional_attributes = hash_values['Attributes']
16
21
 
17
22
  @address = hash_values['LocationAddress']
23
+ @communication_media = hash_values['CommunicationMedia']
18
24
  @image = hash_values.dig('CatalogImagesFullPath', 'MainLogo')
19
25
  @items = Array.wrap(hash_values.dig('Items', 'Item')).collect { |item_hash| RDC::Item.new(item_hash) }
20
26
  end
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'RDC/request'
3
+ require_relative 'request'
4
4
 
5
5
  module RDC
6
6
  class Sku
7
7
  class << self
8
8
  def validate(sku_id)
9
- request = Request.new("/validate_sku?sku=#{sku_id}")
10
- reponse = request.get
9
+ request = Request.new("/validate_sku/?sku=#{sku_id}")
10
+ response = request.get
11
11
  response.json
12
12
  end
13
13
 
14
14
  def verify_inventory_and_price(skus)
15
- request = Request.new("/verify_inventory_and_price?sku=#{skus}")
16
- reponse = request.get
15
+ request = Request.new("/verify_inventory_and_price/?sku=#{skus}")
16
+ response = request.get
17
17
  response.json
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module RDC
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RDC
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - davidrichey
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-12-08 00:00:00.000000000 Z
12
+ date: 2020-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 5.2.3
20
+ version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 5.2.3
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: net-sftp
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +75,7 @@ files:
75
75
  - lib/RDC/cart.rb
76
76
  - lib/RDC/catalog.rb
77
77
  - lib/RDC/item.rb
78
+ - lib/RDC/order.rb
78
79
  - lib/RDC/request.rb
79
80
  - lib/RDC/restaurant.rb
80
81
  - lib/RDC/restaurant_info.rb
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
- rubygems_version: 3.0.3
106
+ rubygems_version: 3.1.2
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: Ruby gem that wraps restaurants.com API