hudu 0.3.1 → 0.3.2
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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +22 -10
- data/hudu.gemspec +1 -1
- data/lib/hudu/asset_helper.rb +8 -3
- data/lib/hudu/client.rb +13 -6
- data/lib/hudu/version.rb +1 -1
- metadata +5 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1e4245c0dce3f094901ea8fdfbcf9b4c2d395b702968d5b869e60dad16adfc5
|
4
|
+
data.tar.gz: 2e44553c6bbac29f51fae2453a55c36b5fdeb26745cabf73c4cb6cfcc97e2eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bc275aebd8cb6dbf89be44e4fdd59eb24761ab5d7b63c8687cf480f5ad6a3074dc911850705881e1bc2b173979393b6a0a859c6e13c7077e151d1853c71fe2d
|
7
|
+
data.tar.gz: c50428e0ec1922c8cc11fc1710ce82d99af88e1ac110c2a559da7b6baeed3c3183b5e8a28087e79e8bc40434baabb3ac9aef90d548b57941ce371152866b1bbd
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
3
|
## [0.1.0] - 2024-02-20
|
4
|
+
|
4
5
|
- Initial release
|
5
6
|
|
6
7
|
## [0.2.0] - 2024-03-13
|
8
|
+
|
7
9
|
- update_company_asset added
|
8
10
|
|
9
11
|
## [0.3.0] - 2024-03-13
|
12
|
+
|
10
13
|
- throtling connection rate
|
11
14
|
|
12
15
|
## [0.3.1] - 2024-03-13
|
16
|
+
|
13
17
|
- rubocop fixes
|
18
|
+
|
19
|
+
## [0.3.2] - 2025-03-20
|
20
|
+
|
21
|
+
- update wrapi dependency
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Hudu API
|
2
|
+
|
2
3
|
[](https://rubygems.org/gems/hudu)
|
3
4
|
[](https://codeclimate.com/github/jancotanis/hudu/maintainability)
|
4
5
|
[](https://codeclimate.com/github/jancotanis/hudu/test_coverage)
|
@@ -17,15 +18,20 @@ gem 'hudu'
|
|
17
18
|
|
18
19
|
And then execute:
|
19
20
|
|
20
|
-
|
21
|
+
```console
|
22
|
+
> bundle install
|
23
|
+
```
|
21
24
|
|
22
25
|
Or install it yourself as:
|
23
26
|
|
24
|
-
|
27
|
+
```console
|
28
|
+
> gem install hudu
|
29
|
+
```
|
25
30
|
|
26
31
|
## Usage
|
27
32
|
|
28
|
-
Before you start making the requests to API provide the endpoint and
|
33
|
+
Before you start making the requests to API provide the endpoint and
|
34
|
+
api key using the configuration wrapping.
|
29
35
|
|
30
36
|
```ruby
|
31
37
|
require 'hudu'
|
@@ -44,20 +50,23 @@ client.login
|
|
44
50
|
```
|
45
51
|
|
46
52
|
## Resources
|
53
|
+
|
47
54
|
### Authentication
|
48
|
-
|
55
|
+
|
56
|
+
```ruby
|
49
57
|
# setup
|
50
58
|
#
|
51
59
|
client.login
|
52
60
|
```
|
61
|
+
|
53
62
|
|Resource|API endpoint|Description|
|
54
63
|
|:--|:--|:--|
|
55
64
|
|.login| none |uses api_info to check if credentials are correct. Raises Hudu:AuthenticationError incase this fails|
|
56
65
|
|
57
|
-
|
58
|
-
|
59
66
|
### Data resources
|
67
|
+
|
60
68
|
Endpoint for data related requests
|
69
|
+
|
61
70
|
```ruby
|
62
71
|
|
63
72
|
# list all asset layouts/fields for a company
|
@@ -99,17 +108,20 @@ end
|
|
99
108
|
2. Add release to [CHANGELOG.md](CHANGELOG.md)
|
100
109
|
3. Commit.
|
101
110
|
4. Test build.
|
102
|
-
```
|
103
|
-
> rake build
|
104
111
|
|
112
|
+
```console
|
113
|
+
> rake build
|
105
114
|
```
|
115
|
+
|
106
116
|
5. Release
|
107
|
-
|
117
|
+
|
118
|
+
```console
|
108
119
|
> rake release
|
120
|
+
```
|
109
121
|
|
110
122
|
## Contributing
|
111
123
|
|
112
|
-
Bug reports and pull requests are welcome on GitHub
|
124
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/jancotanis/hudu).
|
113
125
|
|
114
126
|
## License
|
115
127
|
|
data/hudu.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
30
|
s.platform = Gem::Platform::RUBY
|
31
31
|
s.add_runtime_dependency 'faraday'
|
32
|
-
s.add_runtime_dependency 'wrapi', '>= 0.
|
32
|
+
s.add_runtime_dependency 'wrapi', '>= 0.4.9'
|
33
33
|
s.add_development_dependency 'dotenv'
|
34
34
|
s.add_development_dependency 'minitest'
|
35
35
|
s.add_development_dependency 'rubocop'
|
data/lib/hudu/asset_helper.rb
CHANGED
@@ -11,9 +11,13 @@ module Hudu
|
|
11
11
|
# @example
|
12
12
|
# asset = SomeAssetEntity.new(attributes: { id: 1, name: "Asset 1", company_id: 101 }, fields: [field1, field2])
|
13
13
|
# Hudu::AssetHelper.construct_asset(asset)
|
14
|
-
# # => { asset:
|
14
|
+
# # => { asset:
|
15
|
+
# # { id: 1, company_id: 101, asset_layout_id: nil, slug: nil, name: "Asset 1", custom_fields: [...]
|
16
|
+
# # }
|
17
|
+
# # }
|
15
18
|
def self.construct_asset(asset)
|
16
|
-
custom_asset = asset.attributes.slice(
|
19
|
+
custom_asset = asset.attributes.slice(
|
20
|
+
*%w[
|
17
21
|
id company_id asset_layout_id slug name
|
18
22
|
primary_serial primary_model primary_mail
|
19
23
|
primary_manufacturer
|
@@ -47,7 +51,8 @@ module Hudu
|
|
47
51
|
# Formats custom fields into a standardized hash structure.
|
48
52
|
#
|
49
53
|
# @param fields [Array<Object>] A collection of field objects, each expected to respond to `label` and `value`.
|
50
|
-
# @return [Array<Hash>] An array containing a single hash mapping field labels
|
54
|
+
# @return [Array<Hash>] An array containing a single hash mapping field labels
|
55
|
+
# (downcased and underscored) to their values.
|
51
56
|
#
|
52
57
|
# @example
|
53
58
|
# fields = [Field.new(label: "Warranty", value: "2025"), Field.new(label: "Location", value: "NYC")]
|
data/lib/hudu/client.rb
CHANGED
@@ -4,10 +4,10 @@ require File.expand_path('api', __dir__)
|
|
4
4
|
require File.expand_path('asset_helper', __dir__)
|
5
5
|
|
6
6
|
module Hudu
|
7
|
-
# The Client class serves as a wrapper for the Hudu REST API, providing methods to interact
|
7
|
+
# The Client class serves as a wrapper for the Hudu REST API, providing methods to interact
|
8
8
|
# with various Hudu resources.
|
9
9
|
#
|
10
|
-
# This class dynamically defines methods to fetch, create, update, and manipulate Hudu resources
|
10
|
+
# This class dynamically defines methods to fetch, create, update, and manipulate Hudu resources
|
11
11
|
# such as companies, articles, assets, and more.
|
12
12
|
#
|
13
13
|
# @example Basic Usage
|
@@ -16,7 +16,6 @@ module Hudu
|
|
16
16
|
# client.update_company(1, { name: "Updated Company" }) # Update a company
|
17
17
|
# client.create_company({ name: "New Company" }) # Create a new company
|
18
18
|
class Client < API
|
19
|
-
|
20
19
|
# Dynamically defines methods for interacting with Hudu API resources.
|
21
20
|
#
|
22
21
|
# Depending on the arguments, this will define methods to:
|
@@ -68,7 +67,6 @@ module Hudu
|
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
|
-
|
72
70
|
# Define API endpoints for various resources
|
73
71
|
api_endpoint :api_info
|
74
72
|
api_endpoint :activity_logs
|
@@ -117,7 +115,10 @@ module Hudu
|
|
117
115
|
# @param asset [Object] The asset object to update.
|
118
116
|
# @return [Hash] The updated asset data.
|
119
117
|
def update_company_asset(asset)
|
120
|
-
hudu_data(
|
118
|
+
hudu_data(
|
119
|
+
put(api_url("companies/#{asset.company_id}/assets/#{asset.id}"), AssetHelper.construct_asset(asset), false),
|
120
|
+
:asset
|
121
|
+
)
|
121
122
|
end
|
122
123
|
|
123
124
|
# Creates a new asset for a company.
|
@@ -127,7 +128,13 @@ module Hudu
|
|
127
128
|
# @param fields [Array<Hash>] The custom fields for the asset.
|
128
129
|
# @return [Hash] The newly created asset data.
|
129
130
|
def create_company_asset(company_id, asset_layout, fields)
|
130
|
-
hudu_data(
|
131
|
+
hudu_data(
|
132
|
+
post(
|
133
|
+
api_url("companies/#{company_id}/assets"),
|
134
|
+
AssetHelper.create_asset(asset_layout.name, asset_layout.id, fields),
|
135
|
+
false
|
136
|
+
), :asset
|
137
|
+
)
|
131
138
|
end
|
132
139
|
|
133
140
|
# Constructs the full API URL for a given path.
|
data/lib/hudu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hudu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janco Tanis
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-20 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: faraday
|
@@ -30,14 +29,14 @@ dependencies:
|
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
32
|
+
version: 0.4.9
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
39
|
+
version: 0.4.9
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: dotenv
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +93,6 @@ dependencies:
|
|
94
93
|
- - ">="
|
95
94
|
- !ruby/object:Gem::Version
|
96
95
|
version: '0'
|
97
|
-
description:
|
98
96
|
email: gems@jancology.com
|
99
97
|
executables: []
|
100
98
|
extensions: []
|
@@ -125,7 +123,6 @@ licenses:
|
|
125
123
|
metadata:
|
126
124
|
homepage_uri: https://rubygems.org/gems/hudu
|
127
125
|
source_code_uri: https://github.com/jancotanis/hudu
|
128
|
-
post_install_message:
|
129
126
|
rdoc_options: []
|
130
127
|
require_paths:
|
131
128
|
- lib
|
@@ -140,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
137
|
- !ruby/object:Gem::Version
|
141
138
|
version: '0'
|
142
139
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
140
|
+
rubygems_version: 3.6.2
|
145
141
|
specification_version: 4
|
146
142
|
summary: A Ruby wrapper for the Hudu APIs (readonly)
|
147
143
|
test_files: []
|