sourcescrub 0.0.6 → 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: 6de299d6fd6488b24f851914c38bf4a85dcd312a156445f2f357da4228a63c6f
4
- data.tar.gz: 8f5a7c9a5208a689b5bc404d4b08f4745829ed4099b5335ba278823f2568b5b4
3
+ metadata.gz: 2884125ab5a2d684096e4c2a1107ae6f561671f4122cc7cf34962b74f9e51b64
4
+ data.tar.gz: d34e3f88743020e0eb49d4a7acadeb2fe0451d6742fcbcf1651b5eee08ad3494
5
5
  SHA512:
6
- metadata.gz: 832239e6396f1ddcfff488575bec81676d096e96e3b4b14d15edc5f5b92f9032b4e0d918759b59ddf36ed35672a4b275f8f46233745bce88d9fd829be6c30aa9
7
- data.tar.gz: fbec2f0e813005424144a1f50591dd7057edf8f7bbe961571ee05fb8a4fb0afc4b6b299967aa58dc4849491ef07a3e8c22ef97bd38745c9234e66133e3e986b4
6
+ metadata.gz: a0e4aca28751dbaa64568bbe53ddfae988c538b117d059d66ce5b9c2f37a13119616f2ad6d8d6e3b99d0110796eac6f0a7515e5a43cc03f184fce33c618229f7
7
+ data.tar.gz: 9c8b1e392af7cc0bbd09d81cd6421f115503deb2872a49a58ea9e1ac4efd30c0e0b6be4a439f67dcee80ef415508d9b0972b042e6edda09fa44695b2d4b021cf
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## [0.1.1] - 2020-11-03
4
+
5
+ - Fixing wrong data issue of `currentEmployeeRange` in Company
6
+
7
+ ## [0.0.8] - 2020-08-13
8
+
9
+ - Implement API to request all compnies - `client.companies`
10
+
11
+ ## [0.0.7] - 2020-08-04
12
+
13
+ - Get source data and source compaines - `client.source_companies(source_id)`
14
+ - Get company's employeerange data by domain - `client.company_cards('monday.com', { card_id: 'employeerange' })`
15
+ - Get company's employees data by domain - `client.company_cards('monday.com', { card_id: 'employees' })`
16
+
3
17
  ## [0.0.3] - 2020-06-20
4
18
 
5
19
  - Implement API to request token by user certificate
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sourcescrub (0.0.6)
4
+ sourcescrub (0.1.1)
5
5
  faraday
6
6
 
7
7
  GEM
@@ -26,6 +26,13 @@ module Sourcescrub
26
26
  @card_id
27
27
  ].compact.join('/')
28
28
  end
29
+
30
+ def search_url
31
+ [
32
+ 'search',
33
+ Models::Company::ENDPOINT
34
+ ].compact.join('/')
35
+ end
29
36
  end
30
37
  end
31
38
  end
@@ -18,14 +18,24 @@ module Sourcescrub
18
18
  { 'Authorization' => "Bearer #{@token}" }
19
19
  end
20
20
 
21
+ def companies(args = { limit: 100, offset: 0 })
22
+ api = companies_api(args)
23
+
24
+ Models::CompanyItems.new.parse_response_items(
25
+ nil,
26
+ api.kclass_name,
27
+ get(api.search_url, api.args)
28
+ )
29
+ end
30
+
21
31
  def company(domain, args = {})
22
- api = companies_api(domain, args)
32
+ api = company_api(domain, args)
23
33
 
24
34
  api.sobject.parse_response get(api.request_url, api.args)
25
35
  end
26
36
 
27
37
  def company_cards(domain, args = {})
28
- api = companies_api(domain, args.merge(model_type: company_card_mappings[args[:card_id]]))
38
+ api = company_api(domain, args.merge(model_type: company_card_mappings[args[:card_id]]))
29
39
 
30
40
  Models::CompanyItems.new.parse_response_items(
31
41
  domain,
@@ -62,22 +72,29 @@ module Sourcescrub
62
72
 
63
73
  private
64
74
 
65
- def companies_api(domain, args)
66
- @companies_api ||= Apis::Companies.new(
75
+ def companies_api(args)
76
+ Apis::Companies.new(
77
+ nil,
78
+ { model_type: 'company' }.merge(args)
79
+ )
80
+ end
81
+
82
+ def company_api(domain, args)
83
+ Apis::Companies.new(
67
84
  domain,
68
85
  { model_type: 'company' }.merge(args)
69
86
  )
70
87
  end
71
88
 
72
89
  def source_api(source_id, args)
73
- @source_api ||= Apis::Sources.new(
90
+ Apis::Sources.new(
74
91
  source_id,
75
92
  { model_type: 'source' }.merge(args)
76
93
  )
77
94
  end
78
95
 
79
96
  def source_companies_api(source_id, args)
80
- @source_companies_api ||= Apis::Sources.new(
97
+ Apis::Sources.new(
81
98
  source_id,
82
99
  { model_type: 'company' }.merge(args)
83
100
  )
@@ -90,7 +107,8 @@ module Sourcescrub
90
107
  'financials' => 'financial',
91
108
  'investments' => 'investment',
92
109
  'employees' => 'employee',
93
- 'tags' => 'tag'
110
+ 'tags' => 'tag',
111
+ 'employeerange' => 'employee_range'
94
112
  }
95
113
  end
96
114
  end
@@ -11,5 +11,8 @@ module Sourcescrub
11
11
  autoload :Tag, 'sourcescrub/models/tag'
12
12
  autoload :Person, 'sourcescrub/models/person'
13
13
  autoload :Financial, 'sourcescrub/models/financial'
14
+ autoload :Investment, 'sourcescrub/models/investment'
15
+ autoload :Employee, 'sourcescrub/models/employee'
16
+ autoload :EmployeeRange, 'sourcescrub/models/employee_range'
14
17
  end
15
18
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sourcescrub
4
+ # Models
5
+ module Models
6
+ # Employee
7
+ class EmployeeRange < Entity
8
+ ENDPOINT = 'employeerange'
9
+
10
+ def field_ids
11
+ %w[
12
+ employeeRange
13
+ date
14
+ ]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -25,14 +25,26 @@ module Sourcescrub
25
25
  request: {
26
26
  timeout: 10,
27
27
  open_timeout: 5
28
- }
29
- ).get(uri, *args)
28
+ },
29
+ params: args[0] || {}
30
+ ).get(uri)
30
31
 
31
32
  response_body = response.body
32
33
  raise Error, response_body unless response.status == 200
33
34
 
34
35
  response_body = JSON.parse(response_body)
35
- response_body = {} if response_body.is_a?(Array) && response_body.empty?
36
+ # Processing different cases for investments
37
+ if response_body.is_a?(Array)
38
+ response_body = if response_body.empty?
39
+ {}
40
+ else
41
+ {
42
+ 'total' => response_body.size,
43
+ 'items' => response_body
44
+ }
45
+ end
46
+ end
47
+
36
48
  response_body.merge('headers' => response.headers)
37
49
  end
38
50
 
@@ -29,6 +29,7 @@ module Sourcescrub
29
29
  # Setup attributes
30
30
  attribute_names.each do |attr_name|
31
31
  attr_value = response.dig(attr_name)
32
+ attr_value = nil if attr_name == 'currentEmployeeRange' && attr_value.is_a?(Integer)
32
33
 
33
34
  dynamic_define_method(object, attr_name, attr_value)
34
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sourcescrub
4
- VERSION = '0.0.6'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sourcescrub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -112,6 +112,7 @@ files:
112
112
  - lib/sourcescrub/models/concerns/entity.rb
113
113
  - lib/sourcescrub/models/concerns/source_items.rb
114
114
  - lib/sourcescrub/models/employee.rb
115
+ - lib/sourcescrub/models/employee_range.rb
115
116
  - lib/sourcescrub/models/financial.rb
116
117
  - lib/sourcescrub/models/investment.rb
117
118
  - lib/sourcescrub/models/person.rb