companies_house_hub 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
  SHA256:
3
- metadata.gz: 15368ba8f4030e66bbd7a356116063606bbe8ae0c3a58172fe27bcad307ea327
4
- data.tar.gz: 30026ddb39dcbc297f3a41c13cdf54e36113341cd97a013a2b857f9b4f10769b
3
+ metadata.gz: c86759b60db04a511fc4032bba8893c5c038e1ece25fd619fc5bf36ba9d3c723
4
+ data.tar.gz: 0af0d49515a6ff50ef524bee5c09197413662b0a56c83200ed4ce35cbce58aba
5
5
  SHA512:
6
- metadata.gz: e6297b90251e9fba7eae29c2f571324c5e87c8c425810664433dc15e88fd6871fa21468703396fd7b6f6c42bcae54cead9fc5b5ccf36f352d3074f6d1980f05d
7
- data.tar.gz: 177853a604528af01f3cb04ca8426d2a0911f5d17a04f98db70704890e0958eb22809cb15a0b6c799fa3133d5107c70d9a39e94fea355b2c4ee11e98a31dae7f
6
+ metadata.gz: e3d8d79bb0ac051de83e906ed01b53ca917442ea05924eab841c9ec3156330d23f5f5b3091aec5b81ce09eafc4f089e5ba5cb876a60dc3f9f5f1bc6d42a0d9df
7
+ data.tar.gz: ea281426979ff2bf93bc6d2c1e312a7c3e84788d396f1a787b65c4b9b629ceb201709c51b5f3df62c9b1d9e8a10ae5cf38c286c5bf8b97253955f61373ff7e88
@@ -38,8 +38,9 @@ module CompaniesHouseHub
38
38
  @action_date = json.dig(:action_date)
39
39
  @date = json.dig(:date)
40
40
  @type = json.dig(:type)
41
- @barcode = json.dig(:barcode)
42
41
  @links = json.dig(:links)
42
+ @transaction_id = json.dig(:transaction_id) # helps on barcode generation
43
+ @barcode = json.dig(:barcode) || generate_barcode
43
44
  @description_values = json.dig(:description_values)
44
45
  end
45
46
 
@@ -54,5 +55,16 @@ module CompaniesHouseHub
54
55
 
55
56
  URI.join(DOCUMENT_URL, document_path).to_s
56
57
  end
58
+
59
+ private
60
+
61
+ # Sometimes the barcode comes as nil for some reason so we generate one based on the url. If the
62
+ # URL is also not defined then we hope for the best and use other variables.
63
+ def generate_barcode
64
+ string = @links[:self] if @links
65
+ string ||= [@description, @type, @transaction_id].compact.join
66
+
67
+ Digest::SHA1.hexdigest(string)[0..6].upcase
68
+ end
57
69
  end
58
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompaniesHouseHub
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: companies_house_hub
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
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-08 00:00:00.000000000 Z
11
+ date: 2018-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday