crunchbase4 0.2.4 → 0.2.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: ce0e0ef863b2ccbcdf683719fb8a36ba0a900208e1a6ff13a69b6c8f7f6acd90
4
- data.tar.gz: 4ec2bfcea56efe70cff7e9831de381b46fb5fb0811db889dd70fb17c111f393c
3
+ metadata.gz: b2e94aa6bd2ebe2d92291b2566572e4436e65c9562ee8425d26b50917e926f2f
4
+ data.tar.gz: e44770e8b5d92ecbc2a9deda44007d51aaf63038ffaf2127b1e58852b07b5d95
5
5
  SHA512:
6
- metadata.gz: 4b84de4848db6f199c01a30f6f36111abc0ce26e11d1dc81c64c229be4c5e405cbe403c05ba8021361088da78dd5c1a7806a1d0d251b0e7f9851d2fef492df6a
7
- data.tar.gz: 88d4857e5118750877df2c3a4e0833f0c44d5b1c04dbad092b5771c56e1ec1177d639817f50bd9f29cdaedb5e9ddbe5e5b5043a7d8bec6bb3e2cc5ebb1454367
6
+ metadata.gz: 2d808d02e7619ffaba3990f79d989974361d6233d6fdebd8260cfc6eaed68bf34477d761a919defa0346e5aad9b1b1b9810752316d879a3fcc1cbeb599faea0d
7
+ data.tar.gz: 66dbd1d99bb4c0c052a511264e2e424f26ff09ff4d1d7bc3a9abb57748561a5c13c99823677843555fafd9ad24f0c41fc518fb0223aebc3a63d06f249984d0ba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crunchbase4 (0.2.4)
4
+ crunchbase4 (0.2.6)
5
5
  faraday
6
6
  faraday_curl
7
7
  faraday_middleware
data/README.md CHANGED
@@ -433,6 +433,18 @@ args = {
433
433
  after_id: 'uuid' # optional
434
434
  }
435
435
 
436
+ response = client.recent_updates(args)
437
+
438
+ args = {
439
+ scope_name: 'press_reference', # must
440
+ from_date: '2020-05-05', # optional
441
+ to_date: '2020-05-05', # optional
442
+ field_ids: %w[title posted_on publisher], # default %[uuid created_at updated_at]
443
+ sort: 'desc' # default `desc`
444
+ before_id: 'uuid' # optional
445
+ after_id: 'uuid' # optional
446
+ }
447
+
436
448
  response = client.recent_updates(args)
437
449
  ```
438
450
 
@@ -27,33 +27,33 @@ module Crunchbase
27
27
  # after_id should be the uuid of the last item in the current page. May not be provided simultaneously with before_id.
28
28
  def query_parameters(args)
29
29
  order_field_ids = args[:order_field_ids] || ['updated_at']
30
- order_conditions = order_field_ids.map { |field_id| { 'field_id' => field_id, 'sort' => (args[:sort] || 'desc'), 'nulls' => 'last' } }
30
+ order_conditions = order_field_ids.map do |field_id|
31
+ {
32
+ 'field_id' => field_id,
33
+ 'sort' => (args[:sort] || 'desc'),
34
+ 'nulls' => 'last'
35
+ }
36
+ end
31
37
 
32
38
  params = {
33
39
  'field_ids' => default_field_ids + (args[:field_ids] || []).uniq,
34
40
  'order' => order_conditions,
35
41
  'limit' => args[:limit] || 1000
36
42
  }
37
-
38
- unless args[:date].nil?
39
- params.merge!(
40
- 'query' => [
41
- {
42
- 'type' => 'predicate',
43
- 'field_id' => order_field_ids[0],
44
- 'operator_id' => 'gte',
45
- 'values' => [
46
- args[:date]
47
- ]
48
- }
49
- ]
50
- )
51
- end
43
+ # Pagination
52
44
  params['before_id'] = args[:before_id] unless args[:before_id].nil?
53
45
  params['after_id'] = args[:after_id] unless args[:after_id].nil?
46
+
47
+ # Date Ranges
48
+ unless (queries = build_predicate_queries(args, order_field_ids)).empty?
49
+ params['query'] = queries
50
+ end
51
+
54
52
  params
55
53
  end
56
54
 
55
+ private
56
+
57
57
  def default_field_ids
58
58
  @default_field_ids ||= %w[
59
59
  uuid
@@ -61,6 +61,34 @@ module Crunchbase
61
61
  updated_at
62
62
  ]
63
63
  end
64
+
65
+ def build_predicate_queries(args, order_field_ids)
66
+ # Date Ranges
67
+ queries = []
68
+ if !args[:date].nil? || !args[:from_date].nil?
69
+ queries << {
70
+ 'type' => 'predicate',
71
+ 'field_id' => order_field_ids[0],
72
+ 'operator_id' => 'gte',
73
+ 'values' => [
74
+ args[:date] || args[:from_date]
75
+ ]
76
+ }
77
+ end
78
+
79
+ unless args[:to_date].nil?
80
+ queries << {
81
+ 'type' => 'predicate',
82
+ 'field_id' => order_field_ids[0],
83
+ 'operator_id' => 'lte',
84
+ 'values' => [
85
+ args[:to_date]
86
+ ]
87
+ }
88
+ end
89
+
90
+ queries
91
+ end
64
92
  end
65
93
  end
66
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crunchbase
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-18 00:00:00.000000000 Z
11
+ date: 2024-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday