ruby-brightpearl 0.5.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 +11 -0
- data/Gemfile +1 -5
- data/Gemfile.lock +17 -7
- 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.rb +5 -0
- data/lib/brightpearl/version.rb +1 -1
- data/playground.rb +5 -1
- data/ruby-brightpearl.gemspec +7 -3
- metadata +62 -4
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,16 +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
|
+
|
3
9
|
## [0.5.0]
|
10
|
+
|
4
11
|
- Add new resource OrderCustomField
|
5
12
|
- Improve test environment to use different bp credentials without breaking the cassettes
|
6
13
|
|
7
14
|
## [0.3.0] - 2022-02-03
|
15
|
+
|
8
16
|
- New resource TaxCode
|
9
17
|
- Fix minor typos
|
10
18
|
- New optional config `debug_mode`
|
19
|
+
|
11
20
|
## [0.3.0] - 2022-02-03
|
12
21
|
- New resource ProductAvailability
|
22
|
+
|
13
23
|
## [0.2.0] - 2022-02-02
|
24
|
+
|
14
25
|
- Add refresh token mechanic with method `use_refresh_token`
|
15
26
|
- Change config values
|
16
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,20 +9,27 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
addressable (2.8.0)
|
11
11
|
public_suffix (>= 2.0.2, < 5.0)
|
12
|
-
|
12
|
+
base64 (0.3.0)
|
13
|
+
bigdecimal (3.2.2)
|
13
14
|
byebug (11.1.3)
|
15
|
+
coderay (1.1.3)
|
14
16
|
crack (0.4.5)
|
15
17
|
rexml
|
16
|
-
csv (3.3.
|
18
|
+
csv (3.3.5)
|
17
19
|
diff-lcs (1.5.0)
|
20
|
+
dotenv (3.1.8)
|
18
21
|
hashdiff (1.0.1)
|
19
|
-
httparty (0.23.
|
22
|
+
httparty (0.23.1)
|
20
23
|
csv
|
21
24
|
mini_mime (>= 1.0.0)
|
22
25
|
multi_xml (>= 0.5.2)
|
26
|
+
method_source (1.1.0)
|
23
27
|
mini_mime (1.1.5)
|
24
|
-
multi_xml (0.7.
|
28
|
+
multi_xml (0.7.2)
|
25
29
|
bigdecimal (~> 3.1)
|
30
|
+
pry (0.15.2)
|
31
|
+
coderay (~> 1.1)
|
32
|
+
method_source (~> 1.0)
|
26
33
|
public_suffix (4.0.6)
|
27
34
|
rake (13.0.6)
|
28
35
|
rexml (3.2.5)
|
@@ -39,7 +46,8 @@ GEM
|
|
39
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
47
|
rspec-support (~> 3.10.0)
|
41
48
|
rspec-support (3.10.3)
|
42
|
-
vcr (6.
|
49
|
+
vcr (6.3.1)
|
50
|
+
base64
|
43
51
|
webmock (3.14.0)
|
44
52
|
addressable (>= 2.8.0)
|
45
53
|
crack (>= 0.3.2)
|
@@ -50,10 +58,12 @@ PLATFORMS
|
|
50
58
|
|
51
59
|
DEPENDENCIES
|
52
60
|
byebug
|
61
|
+
dotenv
|
62
|
+
pry
|
53
63
|
rake (~> 13.0)
|
54
64
|
rspec (~> 3.0)
|
55
65
|
ruby-brightpearl!
|
56
|
-
vcr (~> 6.
|
66
|
+
vcr (~> 6.3.1)
|
57
67
|
webmock
|
58
68
|
|
59
69
|
BUNDLED WITH
|
@@ -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
|
@@ -1,10 +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'
|
7
11
|
require 'brightpearl/resources/order_custom_field'
|
12
|
+
|
8
13
|
require 'brightpearl/resources/product'
|
9
14
|
require 'brightpearl/resources/product_price'
|
10
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: 2025-
|
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,6 +152,8 @@ 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
|
100
158
|
- lib/brightpearl/resources/order_custom_field.rb
|
101
159
|
- lib/brightpearl/resources/order_row.rb
|