ruby-brightpearl 0.4.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -5
- data/Gemfile.lock +21 -9
- data/README.md +24 -0
- data/lib/brightpearl/resources/customer.rb +60 -0
- data/lib/brightpearl/resources/customer_custom_field.rb +18 -0
- data/lib/brightpearl/resources/order.rb +1 -1
- data/lib/brightpearl/resources/order_custom_field.rb +19 -0
- data/lib/brightpearl/resources.rb +6 -0
- data/lib/brightpearl/version.rb +1 -1
- data/playground.rb +5 -1
- data/ruby-brightpearl.gemspec +7 -3
- metadata +64 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80cab051224d81b25426eb10655cbc17a7671befe929070149f9f8f0e15d7a0
|
4
|
+
data.tar.gz: f3123fd3ed140e7609c4b8001e3550442432ec7758fe9d7f1509d5950d27389e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a0a2a922874b73cf68f788338c7ebf9b3b5c925a8fa211c009dd09a2e37f891b4d3bb45d5d65043907b1b4302aba4506608549debe5feb2932b65cb0cddfc21
|
7
|
+
data.tar.gz: c5b1cecc26f306eddcd7be95374c809704d925fb8238afc9d2ff0c9e4058eeb45e9685aeb38c506262a80977432d274c5a886aa3c051cd085bfa8aa86d5647a1
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.6.0]
|
4
|
+
|
5
|
+
- New resource `Customer`
|
6
|
+
- New resource `CustomerCustomField`
|
7
|
+
- Minor fixes on development libs
|
8
|
+
|
9
|
+
## [0.5.0]
|
10
|
+
|
11
|
+
- Add new resource OrderCustomField
|
12
|
+
- Improve test environment to use different bp credentials without breaking the cassettes
|
13
|
+
|
3
14
|
## [0.3.0] - 2022-02-03
|
15
|
+
|
4
16
|
- New resource TaxCode
|
5
17
|
- Fix minor typos
|
6
18
|
- New optional config `debug_mode`
|
19
|
+
|
7
20
|
## [0.3.0] - 2022-02-03
|
8
21
|
- New resource ProductAvailability
|
22
|
+
|
9
23
|
## [0.2.0] - 2022-02-02
|
24
|
+
|
10
25
|
- Add refresh token mechanic with method `use_refresh_token`
|
11
26
|
- Change config values
|
12
27
|
- Add refresh_token to allow automatic update of tokens when calling the new method `use_refresh_token`
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-brightpearl (0.
|
4
|
+
ruby-brightpearl (0.6.0)
|
5
5
|
httparty (~> 0.20)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,18 +9,27 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
addressable (2.8.0)
|
11
11
|
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
base64 (0.3.0)
|
13
|
+
bigdecimal (3.2.2)
|
12
14
|
byebug (11.1.3)
|
15
|
+
coderay (1.1.3)
|
13
16
|
crack (0.4.5)
|
14
17
|
rexml
|
18
|
+
csv (3.3.5)
|
15
19
|
diff-lcs (1.5.0)
|
20
|
+
dotenv (3.1.8)
|
16
21
|
hashdiff (1.0.1)
|
17
|
-
httparty (0.
|
18
|
-
|
22
|
+
httparty (0.23.1)
|
23
|
+
csv
|
24
|
+
mini_mime (>= 1.0.0)
|
19
25
|
multi_xml (>= 0.5.2)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
method_source (1.1.0)
|
27
|
+
mini_mime (1.1.5)
|
28
|
+
multi_xml (0.7.2)
|
29
|
+
bigdecimal (~> 3.1)
|
30
|
+
pry (0.15.2)
|
31
|
+
coderay (~> 1.1)
|
32
|
+
method_source (~> 1.0)
|
24
33
|
public_suffix (4.0.6)
|
25
34
|
rake (13.0.6)
|
26
35
|
rexml (3.2.5)
|
@@ -37,7 +46,8 @@ GEM
|
|
37
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
47
|
rspec-support (~> 3.10.0)
|
39
48
|
rspec-support (3.10.3)
|
40
|
-
vcr (6.
|
49
|
+
vcr (6.3.1)
|
50
|
+
base64
|
41
51
|
webmock (3.14.0)
|
42
52
|
addressable (>= 2.8.0)
|
43
53
|
crack (>= 0.3.2)
|
@@ -48,10 +58,12 @@ PLATFORMS
|
|
48
58
|
|
49
59
|
DEPENDENCIES
|
50
60
|
byebug
|
61
|
+
dotenv
|
62
|
+
pry
|
51
63
|
rake (~> 13.0)
|
52
64
|
rspec (~> 3.0)
|
53
65
|
ruby-brightpearl!
|
54
|
-
vcr (~> 6.
|
66
|
+
vcr (~> 6.3.1)
|
55
67
|
webmock
|
56
68
|
|
57
69
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -119,6 +119,30 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
119
119
|
|
120
120
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
121
121
|
|
122
|
+
## Testing
|
123
|
+
|
124
|
+
Before you can you tests, you have to setup some env variables:
|
125
|
+
* RUBY_BRIGHTPEARL_ENDPOINT: The API endpoint to use, e.g. https://ws-use.brightpearl.com
|
126
|
+
* RUBY_BRIGHTPEARL_APP_REF: The app ref to use, e.g. barulu
|
127
|
+
* RUBY_BRIGHTPEARL_DEV_REF: The dev ref to use, e.g. barulu
|
128
|
+
* RUBY_BRIGHTPEARL_ACCOUNT: The account to use, e.g. barulu
|
129
|
+
* RUBY_BRIGHTPEARL_TOKEN: The token to use, e.g. barulu
|
130
|
+
|
131
|
+
You have to fetch these yourself.
|
132
|
+
|
133
|
+
## Release
|
134
|
+
|
135
|
+
To release a new version follow these steps:,
|
136
|
+
1. Update CHANGELOG.md with the new version changes
|
137
|
+
2. Update the version number in `version.rb`
|
138
|
+
3. Execute bundle to update version on `Gemfile.lock` automatically
|
139
|
+
4. Commit the changes and change the branch to `main`
|
140
|
+
5. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
141
|
+
|
142
|
+
> Remember to execute `bundle exec rake release` on `main` branch
|
143
|
+
> `Gemfile.lock` update for version is done after running `bundle install` with the `version.rb` updated
|
144
|
+
|
145
|
+
|
122
146
|
## Contributing
|
123
147
|
|
124
148
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby-brightpearl. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ruby-brightpearl/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Brightpearl
|
2
|
+
# https://api-docs.brightpearl.com/contact/contact/index.html
|
3
|
+
class Customer < Resource
|
4
|
+
extend Brightpearl::APIOperations::Get
|
5
|
+
extend Brightpearl::APIOperations::Post
|
6
|
+
extend Brightpearl::APIOperations::Patch
|
7
|
+
extend Brightpearl::APIOperations::Options
|
8
|
+
|
9
|
+
attr_accessor :id, :primary_email, :secondary_email, :tertiary_email,
|
10
|
+
:first_name, :last_name, :is_supplier, :company_name,
|
11
|
+
:is_staff, :is_customer, :created_on, :updated_on, :last_contacted_on,
|
12
|
+
:last_ordered_on, :nominal_code, :is_primary, :pri, :sec,
|
13
|
+
:mob, :exact_company_name, :title
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def resource_path
|
17
|
+
"contact-service/contact"
|
18
|
+
end
|
19
|
+
|
20
|
+
# https://api-docs.brightpearl.com/contact/contact/get.html
|
21
|
+
# https://api-docs.brightpearl.com/contact/contact/post.html
|
22
|
+
# https://api-docs.brightpearl.com/contact/contact/patch.html
|
23
|
+
# https://api-docs.brightpearl.com/contact/contact/options.html
|
24
|
+
|
25
|
+
# https://api-docs.brightpearl.com/contact/contact/search.html
|
26
|
+
def search(query_params = {})
|
27
|
+
response = send_request(path: "contact-service/contact-search?#{to_query(query_params)}", method: :get)
|
28
|
+
return response.merge({ # modify final payload to set search results as objects
|
29
|
+
records: response[:payload]["response"]["results"].map { |item| Customer.new(item) },
|
30
|
+
})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# ARA => API Record Array
|
35
|
+
def initialize(ara)
|
36
|
+
@id = ara[0]
|
37
|
+
@primary_email = ara[1]
|
38
|
+
@secondary_email = ara[2]
|
39
|
+
@tertiary_email = ara[3]
|
40
|
+
@first_name = ara[4]
|
41
|
+
@last_name = ara[5]
|
42
|
+
@is_supplier = ara[6]
|
43
|
+
@company_name = ara[7]
|
44
|
+
@is_staff = ara[8]
|
45
|
+
@is_customer = ara[9]
|
46
|
+
@created_on = ara[10]
|
47
|
+
@updated_on = ara[11]
|
48
|
+
@last_contacted_on = ara[12]
|
49
|
+
@last_ordered_on = ara[13]
|
50
|
+
@nominal_code = ara[14]
|
51
|
+
@is_primary = ara[15]
|
52
|
+
@pri = ara[16]
|
53
|
+
@sec = ara[17]
|
54
|
+
@mob = ara[18]
|
55
|
+
@exact_company_name = ara[19]
|
56
|
+
@title = ara[20]
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Brightpearl
|
2
|
+
# Contact custom fields are the user-defined data held against Brightpearl contacts. Several data types are available. Custom fields are separated between Supplier contacts and Customer contacts, and may only be assigned to one of these groups.
|
3
|
+
# https://api-docs.brightpearl.com/contact/custom-field/index.html
|
4
|
+
class CustomerCustomField < Resource
|
5
|
+
class << self
|
6
|
+
# https://api-docs.brightpearl.com/contact/custom-field/get.html
|
7
|
+
def get(contact_id)
|
8
|
+
send_request(path: "contact-service/contact/#{contact_id}/custom-field", method: :get)
|
9
|
+
end
|
10
|
+
|
11
|
+
# https://api-docs.brightpearl.com/contact/custom-field/patch.html
|
12
|
+
def patch(contact_id, params)
|
13
|
+
send_request(path: "contact-service/contact/#{contact_id}/custom-field", method: :patch, body: params)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -60,7 +60,7 @@ module Brightpearl
|
|
60
60
|
@order_shipping_status_id = nil
|
61
61
|
@external_ref = ara["reference"]
|
62
62
|
@installed_integration_instance_id = nil
|
63
|
-
@warehouse_id = ara["
|
63
|
+
@warehouse_id = ara["warehouseId"]
|
64
64
|
@staff_owner_contact_id = ara["assignment"]["current"]["staffOwnerContactId"]
|
65
65
|
@tax_date = ara["invoices"][0] && ara["invoices"][0]["taxDate"]
|
66
66
|
@department_id = nil
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Brightpearl
|
2
|
+
# Order custom fields are user-defined data held against an order.
|
3
|
+
# Custom fields are defined separately for sales and purchase orders.
|
4
|
+
# Field names and data types are shared between every order of the same type. Several data types are available.
|
5
|
+
class OrderCustomField < Resource
|
6
|
+
class << self
|
7
|
+
# https://api-docs.brightpearl.com/order/order-customfields/get.html
|
8
|
+
def get(order_id)
|
9
|
+
send_request(path: "order-service/order/#{order_id}/custom-field", method: :get)
|
10
|
+
end
|
11
|
+
|
12
|
+
# https://api-docs.brightpearl.com/order/order-customfields/patch.html
|
13
|
+
def patch(order_id, params)
|
14
|
+
send_request(path: "order-service/order/#{order_id}/custom-field", method: :patch, body: params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'brightpearl/resource'
|
2
|
+
|
3
|
+
require 'brightpearl/resources/customer'
|
4
|
+
require 'brightpearl/resources/customer_custom_field'
|
5
|
+
|
2
6
|
require 'brightpearl/resources/order'
|
3
7
|
require 'brightpearl/resources/order_row'
|
4
8
|
require 'brightpearl/resources/order_shipping_status'
|
5
9
|
require 'brightpearl/resources/order_status'
|
6
10
|
require 'brightpearl/resources/order_status_update'
|
11
|
+
require 'brightpearl/resources/order_custom_field'
|
12
|
+
|
7
13
|
require 'brightpearl/resources/product'
|
8
14
|
require 'brightpearl/resources/product_price'
|
9
15
|
require 'brightpearl/resources/price_list'
|
data/lib/brightpearl/version.rb
CHANGED
data/playground.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
|
2
2
|
|
3
3
|
require 'pry'
|
4
|
+
require 'dotenv'
|
5
|
+
require 'json'
|
4
6
|
require_relative './lib/brightpearl.rb'
|
5
7
|
|
8
|
+
Dotenv.load('.env')
|
9
|
+
|
6
10
|
Brightpearl.config.api_domain = ENV["RUBY_BRIGHTPEARL_ENDPOINT"]
|
7
11
|
Brightpearl.config.app_ref = ENV["RUBY_BRIGHTPEARL_APP_REF"]
|
8
12
|
Brightpearl.config.dev_ref = ENV["RUBY_BRIGHTPEARL_DEV_REF"]
|
9
13
|
Brightpearl.config.account = ENV["RUBY_BRIGHTPEARL_ACCOUNT"]
|
10
14
|
Brightpearl.config.token = ENV["RUBY_BRIGHTPEARL_TOKEN"] # It expires
|
11
15
|
|
12
|
-
puts "
|
16
|
+
puts "The following request should work without issues if the token is valid"
|
13
17
|
|
14
18
|
puts Brightpearl::Order.get(1)
|
data/ruby-brightpearl.gemspec
CHANGED
@@ -31,13 +31,17 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
|
-
#
|
34
|
+
# Runtime dependencies - what users need to use your gem
|
35
35
|
spec.add_dependency 'httparty', '~> 0.20'
|
36
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
37
36
|
|
38
|
-
|
37
|
+
# Development dependencies - what developers need to work on the gem
|
38
|
+
spec.add_development_dependency("vcr", "~> 6.3.1")
|
39
39
|
spec.add_development_dependency("webmock")
|
40
40
|
spec.add_development_dependency("byebug")
|
41
|
+
spec.add_development_dependency("rspec", "~> 3.0")
|
42
|
+
spec.add_development_dependency("rake", "~> 13.0")
|
43
|
+
spec.add_development_dependency("dotenv")
|
44
|
+
spec.add_development_dependency("pry")
|
41
45
|
|
42
46
|
# For more information and examples about making a new gem, check out our
|
43
47
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-brightpearl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vicvans20
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.3.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.3.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webmock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,62 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '13.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '13.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: dotenv
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
description: Simple Ruby client to interact with brightpearl API.
|
70
126
|
email:
|
71
127
|
- vicvans20@gmail.com
|
@@ -96,7 +152,10 @@ files:
|
|
96
152
|
- lib/brightpearl/errors.rb
|
97
153
|
- lib/brightpearl/resource.rb
|
98
154
|
- lib/brightpearl/resources.rb
|
155
|
+
- lib/brightpearl/resources/customer.rb
|
156
|
+
- lib/brightpearl/resources/customer_custom_field.rb
|
99
157
|
- lib/brightpearl/resources/order.rb
|
158
|
+
- lib/brightpearl/resources/order_custom_field.rb
|
100
159
|
- lib/brightpearl/resources/order_row.rb
|
101
160
|
- lib/brightpearl/resources/order_shipping_status.rb
|
102
161
|
- lib/brightpearl/resources/order_status.rb
|
@@ -133,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
192
|
- !ruby/object:Gem::Version
|
134
193
|
version: '0'
|
135
194
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
195
|
+
rubygems_version: 3.5.3
|
137
196
|
signing_key:
|
138
197
|
specification_version: 4
|
139
198
|
summary: Brightpearl API ruby client.
|