openfoodfacts 0.3.1 → 0.6.0

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.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +13 -6
  3. data/lib/openfoodfacts.rb +8 -1
  4. data/lib/openfoodfacts/additive.rb +6 -6
  5. data/lib/openfoodfacts/allergen.rb +3 -3
  6. data/lib/openfoodfacts/brand.rb +2 -2
  7. data/lib/openfoodfacts/category.rb +3 -3
  8. data/lib/openfoodfacts/city.rb +3 -3
  9. data/lib/openfoodfacts/contributor.rb +3 -3
  10. data/lib/openfoodfacts/country.rb +3 -3
  11. data/lib/openfoodfacts/entry_date.rb +33 -0
  12. data/lib/openfoodfacts/faq.rb +5 -5
  13. data/lib/openfoodfacts/ingredient_that_may_be_from_palm_oil.rb +3 -3
  14. data/lib/openfoodfacts/label.rb +5 -10
  15. data/lib/openfoodfacts/language.rb +33 -0
  16. data/lib/openfoodfacts/last_edit_date.rb +33 -0
  17. data/lib/openfoodfacts/locale.rb +22 -8
  18. data/lib/openfoodfacts/manufacturing_place.rb +3 -3
  19. data/lib/openfoodfacts/mission.rb +72 -0
  20. data/lib/openfoodfacts/number_of_ingredients.rb +33 -0
  21. data/lib/openfoodfacts/nutrition_grade.rb +33 -0
  22. data/lib/openfoodfacts/origin.rb +3 -3
  23. data/lib/openfoodfacts/packager_code.rb +3 -3
  24. data/lib/openfoodfacts/packaging.rb +3 -3
  25. data/lib/openfoodfacts/press.rb +16 -26
  26. data/lib/openfoodfacts/product.rb +26 -30
  27. data/lib/openfoodfacts/product_state.rb +3 -3
  28. data/lib/openfoodfacts/purchase_place.rb +3 -3
  29. data/lib/openfoodfacts/store.rb +3 -3
  30. data/lib/openfoodfacts/trace.rb +3 -3
  31. data/lib/openfoodfacts/user.rb +5 -5
  32. data/lib/openfoodfacts/version.rb +1 -1
  33. data/test/minitest_helper.rb +7 -1
  34. data/test/test_openfoodfacts.rb +151 -25
  35. metadata +36 -57
  36. data/test/fixtures/additives.yml +0 -1963
  37. data/test/fixtures/additives_locale.yml +0 -1963
  38. data/test/fixtures/brands.yml +0 -31542
  39. data/test/fixtures/brands_locale.yml +0 -17498
  40. data/test/fixtures/faq.yml +0 -1078
  41. data/test/fixtures/fetch_product_3029330003533.yml +0 -280
  42. data/test/fixtures/index.yml +0 -510
  43. data/test/fixtures/labels.yml +0 -9091
  44. data/test/fixtures/login_user.yml +0 -38
  45. data/test/fixtures/press.yml +0 -1284
  46. data/test/fixtures/product_3029330003533.yml +0 -280
  47. data/test/fixtures/product_states.yml +0 -910
  48. data/test/fixtures/product_states_locale.yml +0 -1002
  49. data/test/fixtures/products_for_brand.yml +0 -5481
  50. data/test/fixtures/products_for_state.yml +0 -2178
  51. data/test/fixtures/products_with_additive.yml +0 -3130
  52. data/test/fixtures/search_Chocolat.yml +0 -586
  53. data/test/fixtures/search_Chocolat_1_000_000.yml +0 -200
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e50cecb07962505751ce697e3b99797015126ba3
4
- data.tar.gz: 96ec0cee88a120ef8de7fe0327e051f99468a535
2
+ SHA256:
3
+ metadata.gz: 8ee85e6766c13c0afa60c4800d43c99c85282f3544427d725cee0a97023631d9
4
+ data.tar.gz: 054c0a1972297b84f91b7c3d3d96006655d29f755f781800ec80808b297e840f
5
5
  SHA512:
6
- metadata.gz: 2dc910d560c309261f07f6b04f811219e553d5a7664107fe81223425c34d4635e25ae6d134135ef77fbba411a4740e405a2d07128dccde5a20758964cdca7e35
7
- data.tar.gz: 42babde6c10c97618d0478734cfd2fe7a6679fc7cb93f65527bed7bee67a7ae3e6eddde113378fb741116a230d2c91391645288d0cd8fbbd3db4dfab18ca5c24
6
+ metadata.gz: 7e9a7773561119e9b32f16677848dd28b54ce4c31f740d5a1f7b3f9592c6798d739d2815030bd507a4ed8df318f30f3fcaf06f26700f36dd26b67f45e2280099
7
+ data.tar.gz: d188187e2245d87ef1bd051485212f24bce554d7f9add603559617bea6353831535f21dcac65cc008b21492cf50ebdf0b3006359fcf531f7b0bd0ea3d51df5c5
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
- # OpenFoodFacts
1
+ # Open Food Facts
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/openfoodfacts.svg)](http://badge.fury.io/rb/openfoodfacts)
3
+ [![Gem Version](https://badge.fury.io/rb/openfoodfacts.svg)](https://badge.fury.io/rb/openfoodfacts)
4
4
  [![Build Status](https://travis-ci.org/openfoodfacts/openfoodfacts-ruby.svg?branch=master)](https://travis-ci.org/openfoodfacts/openfoodfacts-ruby)
5
+ [![Build status](https://ci.appveyor.com/api/projects/status/tarhvc59fw478das/branch/master?svg=true)](https://ci.appveyor.com/project/nicolasleger/openfoodfacts-ruby/branch/master)
5
6
  [![Dependency Status](https://gemnasium.com/openfoodfacts/openfoodfacts-ruby.svg)](https://gemnasium.com/openfoodfacts/openfoodfacts-ruby)
6
7
  [![Code Climate](https://codeclimate.com/github/openfoodfacts/openfoodfacts-ruby/badges/gpa.svg)](https://codeclimate.com/github/openfoodfacts/openfoodfacts-ruby)
7
- [![Coverage Status](https://coveralls.io/repos/nicolasleger/openfoodfacts-ruby/badge.svg)](https://coveralls.io/r/nicolasleger/openfoodfacts-ruby)
8
- [![Documentation](http://inch-ci.org/github/openfoodfacts/openfoodfacts-ruby.svg?branch=master)](http://inch-ci.org/github/openfoodfacts/openfoodfacts-ruby)
8
+ [![Coverage Status](https://coveralls.io/repos/github/openfoodfacts/openfoodfacts-ruby/badge.svg?branch=master)](https://coveralls.io/github/openfoodfacts/openfoodfacts-ruby?branch=master)
9
+ [![Documentation](https://inch-ci.org/github/openfoodfacts/openfoodfacts-ruby.svg?branch=master)](https://inch-ci.org/github/openfoodfacts/openfoodfacts-ruby)
9
10
 
10
- API Wrapper for [OpenFoodFacts](https://openfoodfacts.org/), the open database about food.
11
+ API Wrapper for [Open Food Facts](https://openfoodfacts.org/), the open database about food.
11
12
 
12
13
  ## Installation
13
14
 
@@ -35,11 +36,17 @@ All data is available for World, French, UK and US version for now. You should u
35
36
  - City
36
37
  - Contributor
37
38
  - Country
39
+ - EntryDate
38
40
  - Faq
39
41
  - IngredientThatMayBeFromPalmOil
40
42
  - Label
43
+ - LastEditDate
44
+ - Language
41
45
  - Locale
42
46
  - ManufacturingPlace
47
+ - Mission
48
+ - NumberOfIngredients
49
+ - NutritionGrade
43
50
  - Origin
44
51
  - PackagerCode
45
52
  - Packaging
@@ -79,7 +86,7 @@ end
79
86
  # Search products
80
87
 
81
88
  products = Openfoodfacts::Product.search("Chocolate", locale: 'world', page_size: 3)
82
- # => [#<Openfoodfacts::Product _id="3045140105502" code="3045140105502" id="3045140105502" image_small_url="http://en.openfoodfacts.org/images/products/304/514/010/5502/front.7.100.jpg" lc="en" product_name="Milka au lait du Pays Alpin">, #<Openfoodfacts::Product _id="3046920028363" code="3046920028363" id="3046920028363" image_small_url="http://en.openfoodfacts.org/images/products/304/692/002/8363/front.5.100.jpg" lc="en" product_name="Tableta de chocolate negro \"Lindt Excellence\" 85% cacao">, #<Openfoodfacts::Product _id="3046920029759" code="3046920029759" id="3046920029759" image_small_url="http://en.openfoodfacts.org/images/products/304/692/002/9759/front.9.100.jpg" lc="en" product_name="Tableta de chocolate negro \"Lindt Excellence\" 90% cacao">]
89
+ # => [#<Openfoodfacts::Product _id="3045140105502" code="3045140105502" id="3045140105502" image_small_url="https://en.openfoodfacts.org/images/products/304/514/010/5502/front.7.100.jpg" lc="en" product_name="Milka au lait du Pays Alpin">, #<Openfoodfacts::Product _id="3046920028363" code="3046920028363" id="3046920028363" image_small_url="https://en.openfoodfacts.org/images/products/304/692/002/8363/front.5.100.jpg" lc="en" product_name="Tableta de chocolate negro \"Lindt Excellence\" 85% cacao">, #<Openfoodfacts::Product _id="3046920029759" code="3046920029759" id="3046920029759" image_small_url="https://en.openfoodfacts.org/images/products/304/692/002/9759/front.9.100.jpg" lc="en" product_name="Tableta de chocolate negro \"Lindt Excellence\" 90% cacao">]
83
90
 
84
91
  # You might need to fetch full product data from results
85
92
 
@@ -4,11 +4,17 @@ require_relative 'openfoodfacts/category'
4
4
  require_relative 'openfoodfacts/city'
5
5
  require_relative 'openfoodfacts/contributor'
6
6
  require_relative 'openfoodfacts/country'
7
+ require_relative 'openfoodfacts/entry_date'
7
8
  require_relative 'openfoodfacts/faq'
8
9
  require_relative 'openfoodfacts/ingredient_that_may_be_from_palm_oil'
9
10
  require_relative 'openfoodfacts/label'
11
+ require_relative 'openfoodfacts/language'
12
+ require_relative 'openfoodfacts/last_edit_date'
10
13
  require_relative 'openfoodfacts/locale'
11
14
  require_relative 'openfoodfacts/manufacturing_place'
15
+ require_relative 'openfoodfacts/mission'
16
+ require_relative 'openfoodfacts/number_of_ingredients'
17
+ require_relative 'openfoodfacts/nutrition_grade'
12
18
  require_relative 'openfoodfacts/origin'
13
19
  require_relative 'openfoodfacts/packager_code'
14
20
  require_relative 'openfoodfacts/packaging'
@@ -28,6 +34,7 @@ require 'open-uri'
28
34
  module Openfoodfacts
29
35
 
30
36
  DEFAULT_LOCALE = Locale::GLOBAL
37
+ DEFAULT_DOMAIN = 'openfoodfacts.org'
31
38
 
32
39
  class << self
33
40
 
@@ -56,4 +63,4 @@ module Openfoodfacts
56
63
  end
57
64
 
58
65
  end
59
- end
66
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get additives
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- page_url = "http://#{locale}.openfoodfacts.org/#{path}"
20
+ page_url = "https://#{locale}.#{domain}/#{path}"
21
21
 
22
22
  Product.tags_from_page(self, page_url) do |tag|
23
23
  columns = tag.css('td')
@@ -26,10 +26,10 @@ module Openfoodfacts
26
26
  attributes = {
27
27
  "name" => link.text.strip,
28
28
  "url" => URI.join(page_url, link.attr('href')).to_s,
29
- "products_count" => columns[1].text.to_i,
29
+ "products_count" => columns[1].text.to_i
30
30
  }
31
-
32
- riskiness = columns[2].attr('class')
31
+
32
+ riskiness = columns.last.attr('class')
33
33
  if riskiness
34
34
  attributes["riskiness"] = riskiness[/level_(\d+)/, 1].to_i
35
35
  end
@@ -48,4 +48,4 @@ module Openfoodfacts
48
48
  end
49
49
 
50
50
  end
51
- end
51
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get allergens
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -30,4 +30,4 @@ module Openfoodfacts
30
30
  end
31
31
 
32
32
  end
33
- end
33
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get product brands
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get categories
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -30,4 +30,4 @@ module Openfoodfacts
30
30
  end
31
31
 
32
32
  end
33
- end
33
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get cities
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -30,4 +30,4 @@ module Openfoodfacts
30
30
  end
31
31
 
32
32
  end
33
- end
33
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get contributors
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -30,4 +30,4 @@ module Openfoodfacts
30
30
  end
31
31
 
32
32
  end
33
- end
33
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get countries
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -30,4 +30,4 @@ module Openfoodfacts
30
30
  end
31
31
 
32
32
  end
33
- end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'hashie'
2
+
3
+ module Openfoodfacts
4
+ class EntryDate < Hashie::Mash
5
+
6
+ # TODO: Add more locales
7
+ LOCALE_PATHS = {
8
+ 'fr' => 'dates-d-ajout',
9
+ 'uk' => 'entry-dates',
10
+ 'us' => 'entry-dates',
11
+ 'world' => 'entry-dates'
12
+ }
13
+
14
+ class << self
15
+
16
+ # Get entry dates
17
+ #
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
+ if path = LOCALE_PATHS[locale]
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ # Get products with entry date
27
+ #
28
+ def products(page: -1)
29
+ Product.from_website_page(url, page: page, products_count: products_count) if url
30
+ end
31
+
32
+ end
33
+ end
@@ -14,15 +14,15 @@ module Openfoodfacts
14
14
  }
15
15
 
16
16
  class << self
17
- def items(locale: Openfoodfacts::DEFAULT_LOCALE)
17
+ def items(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
18
18
  if path = LOCALE_PATHS[locale]
19
- html = open("http://#{locale}.openfoodfacts.org/#{path}").read
19
+ html = URI.open("https://#{locale}.#{domain}/#{path}").read
20
20
  dom = Nokogiri::HTML.fragment(html)
21
-
21
+
22
22
  titles = dom.css('#main_column h2')
23
23
  titles.each_with_index.map do |item, index|
24
24
  paragraphs = []
25
-
25
+
26
26
  element = item.next_sibling
27
27
  while !element.nil? && element.node_name != 'h2'
28
28
  if element.node_name == 'p'
@@ -47,4 +47,4 @@ module Openfoodfacts
47
47
  end
48
48
 
49
49
  end
50
- end
50
+ end
@@ -15,9 +15,9 @@ module Openfoodfacts
15
15
 
16
16
  # Get ingredients that may be from palm oil
17
17
  #
18
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
19
  if path = LOCALE_PATHS[locale]
20
- Product.tags_from_page(self, "http://#{locale}.openfoodfacts.org/#{path}")
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
21
  end
22
22
  end
23
23
 
@@ -30,4 +30,4 @@ module Openfoodfacts
30
30
  end
31
31
 
32
32
  end
33
- end
33
+ end
@@ -1,10 +1,8 @@
1
1
  require 'hashie'
2
- require 'json'
3
- require 'open-uri'
4
2
 
5
3
  module Openfoodfacts
6
4
  class Label < Hashie::Mash
7
-
5
+
8
6
  # TODO: Add more locales
9
7
  LOCALE_PATHS = {
10
8
  'fr' => 'labels',
@@ -17,12 +15,9 @@ module Openfoodfacts
17
15
 
18
16
  # Get labels
19
17
  #
20
- def all(locale: Openfoodfacts::DEFAULT_LOCALE)
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
21
19
  if path = LOCALE_PATHS[locale]
22
- body = open("http://#{locale}.openfoodfacts.org/#{path}.json").read
23
- json = JSON.parse(body)
24
- json_labels = json['tags']
25
- json_labels.map(&method(:new))
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
26
21
  end
27
22
  end
28
23
 
@@ -31,8 +26,8 @@ module Openfoodfacts
31
26
  # Get products with label
32
27
  #
33
28
  def products(page: -1)
34
- Product.from_api("#{url}.json", page: page) if url
29
+ Product.from_website_page(url, page: page, products_count: products_count) if url
35
30
  end
36
31
 
37
32
  end
38
- end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'hashie'
2
+
3
+ module Openfoodfacts
4
+ class Language < Hashie::Mash
5
+
6
+ # TODO: Add more locales
7
+ LOCALE_PATHS = {
8
+ 'fr' => 'langues',
9
+ 'uk' => 'languages',
10
+ 'us' => 'languages',
11
+ 'world' => 'languages'
12
+ }
13
+
14
+ class << self
15
+
16
+ # Get languages
17
+ #
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
+ if path = LOCALE_PATHS[locale]
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ # Get products with language
27
+ #
28
+ def products(page: -1)
29
+ Product.from_website_page(url, page: page, products_count: products_count) if url
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'hashie'
2
+
3
+ module Openfoodfacts
4
+ class LastEditDate < Hashie::Mash
5
+
6
+ # TODO: Add more locales
7
+ LOCALE_PATHS = {
8
+ 'fr' => 'dates-de-derniere-modification',
9
+ 'uk' => 'last-edit-dates',
10
+ 'us' => 'last-edit-dates',
11
+ 'world' => 'last-edit-dates'
12
+ }
13
+
14
+ class << self
15
+
16
+ # Get last edit dates
17
+ #
18
+ def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
19
+ if path = LOCALE_PATHS[locale]
20
+ Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ # Get products with last edit date
27
+ #
28
+ def products(page: -1)
29
+ Product.from_website_page(url, page: page, products_count: products_count) if url
30
+ end
31
+
32
+ end
33
+ end
@@ -1,3 +1,5 @@
1
+ require 'open-uri'
2
+
1
3
  module Openfoodfacts
2
4
  class Locale < String
3
5
 
@@ -7,14 +9,15 @@ module Openfoodfacts
7
9
 
8
10
  # Get locales
9
11
  #
10
- def all
11
- url = "http://openfoodfacts.org/"
12
- body = open(url).read
13
- dom = Nokogiri.parse(body)
14
-
15
- dom.css('ul li a').map { |locale_link|
16
- locale_from_link(locale_link.attr('href'))
17
- }.uniq.sort
12
+ def all(domain: DEFAULT_DOMAIN)
13
+ path = 'cgi/i18n/countries.pl?_type=query'
14
+ url = "https://#{GLOBAL}.#{domain}/#{path}"
15
+ json = URI.open(url).read
16
+ hash = JSON.parse(json)
17
+
18
+ hash.map { |pair|
19
+ locale_from_pair(pair, domain: domain)
20
+ }.compact
18
21
  end
19
22
 
20
23
  # Return locale from link
@@ -24,6 +27,17 @@ module Openfoodfacts
24
27
  locale unless locale.nil? || locale == 'static'
25
28
  end
26
29
 
30
+ # Return locale from pair
31
+ #
32
+ def locale_from_pair(pair, domain: DEFAULT_DOMAIN)
33
+ code = pair.first
34
+ {
35
+ "name" => pair.last.strip,
36
+ "code" => code,
37
+ "url" => "https://#{code}.#{domain}"
38
+ } if code
39
+ end
40
+
27
41
  end
28
42
 
29
43
  end