shedcloud-partner_api 0.1.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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/release.yml +30 -0
  3. data/.gitignore +13 -0
  4. data/AGENTS.md +47 -0
  5. data/CHANGELOG.md +11 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE +21 -0
  8. data/README.md +173 -0
  9. data/Rakefile +21 -0
  10. data/examples/list_lot_stock.rb +22 -0
  11. data/lib/shedcloud/partner_api/auth.rb +26 -0
  12. data/lib/shedcloud/partner_api/auth_provider.rb +95 -0
  13. data/lib/shedcloud/partner_api/client.rb +72 -0
  14. data/lib/shedcloud/partner_api/errors.rb +54 -0
  15. data/lib/shedcloud/partner_api/hosts.rb +31 -0
  16. data/lib/shedcloud/partner_api/http_client.rb +117 -0
  17. data/lib/shedcloud/partner_api/http_transport.rb +57 -0
  18. data/lib/shedcloud/partner_api/request_options.rb +32 -0
  19. data/lib/shedcloud/partner_api/resources/agreements.rb +29 -0
  20. data/lib/shedcloud/partner_api/resources/base.rb +23 -0
  21. data/lib/shedcloud/partner_api/resources/configurator_sessions.rb +13 -0
  22. data/lib/shedcloud/partner_api/resources/customers.rb +29 -0
  23. data/lib/shedcloud/partner_api/resources/documents.rb +17 -0
  24. data/lib/shedcloud/partner_api/resources/domains.rb +17 -0
  25. data/lib/shedcloud/partner_api/resources/events.rb +53 -0
  26. data/lib/shedcloud/partner_api/resources/leads.rb +33 -0
  27. data/lib/shedcloud/partner_api/resources/locations.rb +25 -0
  28. data/lib/shedcloud/partner_api/resources/lot_stock.rb +15 -0
  29. data/lib/shedcloud/partner_api/resources/orders.rb +61 -0
  30. data/lib/shedcloud/partner_api/resources/payments.rb +17 -0
  31. data/lib/shedcloud/partner_api/resources/products.rb +29 -0
  32. data/lib/shedcloud/partner_api/resources/quotes.rb +49 -0
  33. data/lib/shedcloud/partner_api/resources/stock_templates.rb +19 -0
  34. data/lib/shedcloud/partner_api/resources/users.rb +29 -0
  35. data/lib/shedcloud/partner_api/resources/work_orders.rb +33 -0
  36. data/lib/shedcloud/partner_api/scopes.rb +61 -0
  37. data/lib/shedcloud/partner_api/version.rb +7 -0
  38. data/lib/shedcloud/partner_api/webhooks.rb +72 -0
  39. data/lib/shedcloud/partner_api.rb +35 -0
  40. metadata +112 -0
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'uri'
5
+
6
+ module ShedCloud
7
+ module PartnerApi
8
+ class HttpClient
9
+ def initialize(base_url:, get_access_token:, transport: HttpTransport.new, user_agent: 'shedcloud-ruby/partner-api')
10
+ @base_url = Hosts.trim_trailing_slashes(base_url)
11
+ @get_access_token = get_access_token
12
+ @transport = transport
13
+ @user_agent = user_agent
14
+ end
15
+
16
+ def request(method, path, query: nil, body: nil, headers: {}, skip_auth: false, content_type: 'application/json')
17
+ url = @base_url + path
18
+ if query && !query.empty?
19
+ encoded = self.class.encode_query(query)
20
+ url += "?#{encoded}" unless encoded.empty?
21
+ end
22
+
23
+ request_headers = {
24
+ 'Accept' => 'application/json',
25
+ 'User-Agent' => @user_agent
26
+ }.merge(headers)
27
+
28
+ payload = nil
29
+ unless body.nil?
30
+ payload = if content_type == 'application/x-www-form-urlencoded'
31
+ URI.encode_www_form(body)
32
+ elsif body.empty?
33
+ '{}'
34
+ else
35
+ JSON.generate(body)
36
+ end
37
+ request_headers['Content-Type'] = content_type if content_type
38
+ end
39
+
40
+ unless skip_auth
41
+ token = @get_access_token.call
42
+ raise PartnerApiError.new('no access token available', status: 401) if token.to_s.empty?
43
+
44
+ request_headers['Authorization'] = "Bearer #{token}"
45
+ end
46
+
47
+ response = @transport.send(method, url, request_headers, payload)
48
+ parsed = parse_body(response[:body])
49
+
50
+ if response[:status] < 200 || response[:status] >= 300
51
+ message, code = extract_error(parsed, response[:status].to_s)
52
+ raise PartnerApiError.new(message, status: response[:status], body: parsed, code: code)
53
+ end
54
+
55
+ return nil if parsed.nil?
56
+ raise PartnerApiError.new('partner-api: decode response: expected JSON object', status: 500) unless parsed.is_a?(Hash)
57
+
58
+ parsed
59
+ end
60
+
61
+ def self.encode_query(params)
62
+ out = {}
63
+
64
+ params.each do |key, value|
65
+ key = key.to_s
66
+
67
+ if value.is_a?(QueryValue)
68
+ out[key] = format_query_value(value.value)
69
+ next
70
+ end
71
+
72
+ next if value.nil? || value == '' || value == false || value == 0 || value == 0.0 || value == []
73
+
74
+ if value.is_a?(Array)
75
+ out[key] = value.map { |item| format_query_value(item) }.join(',')
76
+ next
77
+ end
78
+
79
+ out[key] = format_query_value(value)
80
+ end
81
+
82
+ URI.encode_www_form(out)
83
+ end
84
+
85
+ def self.format_query_value(value)
86
+ case value
87
+ when TrueClass, FalseClass then value ? 'true' : 'false'
88
+ else value.to_s
89
+ end
90
+ end
91
+
92
+ private
93
+
94
+ def parse_body(raw)
95
+ return nil if raw.nil? || raw.empty?
96
+
97
+ JSON.parse(raw)
98
+ rescue JSON::ParserError
99
+ raw
100
+ end
101
+
102
+ def extract_error(body, fallback)
103
+ message = fallback
104
+ code = nil
105
+
106
+ return [message, code] unless body.is_a?(Hash)
107
+
108
+ message = body['error_description'] if body['error_description'].is_a?(String) && !body['error_description'].empty?
109
+ message = body['error'] if message == fallback && body['error'].is_a?(String) && !body['error'].empty?
110
+ message = body['message'] if message == fallback && body['message'].is_a?(String) && !body['message'].empty?
111
+ code = body['error'] if body['error'].is_a?(String)
112
+
113
+ [message, code]
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'net/http'
5
+ require 'uri'
6
+
7
+ module ShedCloud
8
+ module PartnerApi
9
+ class HttpTransport
10
+ REQUEST_CLASS = {
11
+ 'GET' => Net::HTTP::Get,
12
+ 'POST' => Net::HTTP::Post,
13
+ 'PUT' => Net::HTTP::Put,
14
+ 'PATCH' => Net::HTTP::Patch,
15
+ 'DELETE' => Net::HTTP::Delete
16
+ }.freeze
17
+
18
+ def send(method, url, headers, body)
19
+ uri = URI(url)
20
+ request = build_request(method, uri, headers, body)
21
+
22
+ response = Net::HTTP.start(
23
+ uri.host,
24
+ uri.port,
25
+ use_ssl: uri.scheme == 'https',
26
+ open_timeout: 30,
27
+ read_timeout: 30
28
+ ) do |http|
29
+ http.request(request)
30
+ end
31
+
32
+ {
33
+ status: response.code.to_i,
34
+ body: response.body.to_s,
35
+ headers: response.each_header.to_h.transform_values { |v| [v] }
36
+ }
37
+ end
38
+
39
+ private
40
+
41
+ def build_request(method, uri, headers, body)
42
+ klass = REQUEST_CLASS[method.to_s.upcase]
43
+ if klass
44
+ request = klass.new(uri)
45
+ headers.each { |name, value| request[name] = value }
46
+ request.body = body unless body.nil?
47
+ return request
48
+ end
49
+
50
+ request = Net::HTTP::GenericRequest.new(method.to_s.upcase, !body.nil?, !body.nil?, uri)
51
+ headers.each { |name, value| request[name] = value }
52
+ request.body = body unless body.nil?
53
+ request
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ # Wraps a query parameter value that must be sent even when falsy (e.g. converted=false).
6
+ QueryValue = Data.define(:value)
7
+
8
+ class RequestOptions
9
+ attr_reader :idempotency_key, :if_match
10
+
11
+ def initialize(idempotency_key: nil, if_match: nil)
12
+ @idempotency_key = idempotency_key
13
+ @if_match = if_match
14
+ end
15
+
16
+ def self.with_idempotency_key(key)
17
+ new(idempotency_key: key)
18
+ end
19
+
20
+ def self.with_if_match(version)
21
+ new(if_match: version)
22
+ end
23
+
24
+ def headers
25
+ out = {}
26
+ out['Idempotency-Key'] = idempotency_key if idempotency_key && !idempotency_key.empty?
27
+ out['If-Match'] = if_match.to_s unless if_match.nil?
28
+ out
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Agreements < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/agreements', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/agreements/#{path_segment(id)}") || {}
13
+ end
14
+
15
+ def active
16
+ @http.request('GET', '/partner/v1/agreements/active') || {}
17
+ end
18
+
19
+ def list_state_legal(agreement_id)
20
+ @http.request('GET', "/partner/v1/agreements/#{path_segment(agreement_id)}/state-legal") || {}
21
+ end
22
+
23
+ def get_state_legal(agreement_id, state)
24
+ @http.request('GET', "/partner/v1/agreements/#{path_segment(agreement_id)}/state-legal/#{path_segment(state)}") || {}
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Base
7
+ def initialize(http)
8
+ @http = http
9
+ end
10
+
11
+ private
12
+
13
+ def path_segment(id)
14
+ URI.encode_www_form_component(id.to_s)
15
+ end
16
+
17
+ def option_headers(options)
18
+ options&.headers || {}
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class ConfiguratorSessions < Base
7
+ def create(body, options: nil)
8
+ @http.request('POST', '/partner/v1/configurator-sessions', body: body, headers: option_headers(options)) || {}
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Customers < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/customers', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/customers/#{path_segment(id)}") || {}
13
+ end
14
+
15
+ def create(body, options: nil)
16
+ @http.request('POST', '/partner/v1/customers', body: body, headers: option_headers(options)) || {}
17
+ end
18
+
19
+ def merge(id, body, options: nil)
20
+ @http.request('POST', "/partner/v1/customers/#{path_segment(id)}/merge", body: body, headers: option_headers(options)) || {}
21
+ end
22
+
23
+ def update(id, body, options: nil)
24
+ @http.request('PATCH', "/partner/v1/customers/#{path_segment(id)}", body: body, headers: option_headers(options)) || {}
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Documents < Base
7
+ def list(params)
8
+ @http.request('GET', '/partner/v1/documents', query: params) || {}
9
+ end
10
+
11
+ def download(id)
12
+ @http.request('GET', "/partner/v1/documents/#{path_segment(id)}/download") || {}
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Domains < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/domains', query: params) || {}
9
+ end
10
+
11
+ def for_location(location_id, params = {})
12
+ @http.request('GET', "/partner/v1/locations/#{path_segment(location_id)}/domains", query: params) || {}
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Events < Base
7
+ def list(params = {})
8
+ query = params.dup
9
+ query[:types] = query[:types].join(',') if query[:types].is_a?(Array)
10
+ @http.request('GET', '/partner/v1/events', query: query) || {}
11
+ end
12
+
13
+ def each(params = {})
14
+ cursor = params[:cursor].to_s
15
+ last_seen = cursor
16
+
17
+ loop do
18
+ page_params = params.dup
19
+ if cursor.empty?
20
+ page_params.delete(:cursor)
21
+ else
22
+ page_params[:cursor] = cursor
23
+ end
24
+
25
+ response = list(page_params)
26
+ data = response['data'].is_a?(Array) ? response['data'] : []
27
+
28
+ data.each do |event|
29
+ result = yield(event)
30
+ return last_seen if result == false
31
+
32
+ last_seen = event['id'] if event['id'].is_a?(String) && !event['id'].empty?
33
+ end
34
+
35
+ break unless response['hasMore'] && response['nextCursor'].is_a?(String) && !response['nextCursor'].empty?
36
+
37
+ cursor = response['nextCursor']
38
+ end
39
+
40
+ last_seen
41
+ end
42
+
43
+ def redeliver(id)
44
+ @http.request('POST', "/partner/v1/events/#{path_segment(id)}/redeliver") || {}
45
+ end
46
+
47
+ def deliveries(params = {})
48
+ @http.request('GET', '/partner/v1/webhook-deliveries', query: params) || {}
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Leads < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/leads', query: params) || {}
9
+ end
10
+
11
+ def create(body, options: nil)
12
+ @http.request('POST', '/partner/v1/leads', body: body, headers: option_headers(options)) || {}
13
+ end
14
+
15
+ def get(id)
16
+ @http.request('GET', "/partner/v1/leads/#{path_segment(id)}") || {}
17
+ end
18
+
19
+ def update(id, body, options: nil)
20
+ @http.request('PATCH', "/partner/v1/leads/#{path_segment(id)}", body: body, headers: option_headers(options)) || {}
21
+ end
22
+
23
+ def update_status(id, body)
24
+ @http.request('POST', "/partner/v1/leads/#{path_segment(id)}/status", body: body) || {}
25
+ end
26
+
27
+ def status_history(id, params = {})
28
+ @http.request('GET', "/partner/v1/leads/#{path_segment(id)}/status-history", query: params) || {}
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Locations < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/locations', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/locations/#{path_segment(id)}") || {}
13
+ end
14
+
15
+ def create(body, options: nil)
16
+ @http.request('POST', '/partner/v1/locations', body: body, headers: option_headers(options)) || {}
17
+ end
18
+
19
+ def update(id, body)
20
+ @http.request('PATCH', "/partner/v1/locations/#{path_segment(id)}", body: body) || {}
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module ShedCloud
6
+ module PartnerApi
7
+ module Resources
8
+ class LotStock < Base
9
+ def list(params = {})
10
+ @http.request('GET', '/partner/v1/lot-stock', query: params) || {}
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Orders < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/orders', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/orders/#{path_segment(id)}") || {}
13
+ end
14
+
15
+ def create(body, options: nil)
16
+ @http.request('POST', '/partner/v1/orders', body: body, headers: option_headers(options)) || {}
17
+ end
18
+
19
+ def add_line_item(id, body)
20
+ @http.request('POST', "/partner/v1/orders/#{path_segment(id)}/line-items", body: body) || {}
21
+ end
22
+
23
+ def delete_line_item(id, line_id)
24
+ @http.request('DELETE', "/partner/v1/orders/#{path_segment(id)}/line-items/#{path_segment(line_id)}")
25
+ end
26
+
27
+ def update(id, body, options: nil)
28
+ @http.request('PATCH', "/partner/v1/orders/#{path_segment(id)}", body: body, headers: option_headers(options)) || {}
29
+ end
30
+
31
+ def update_status(id, body)
32
+ @http.request('POST', "/partner/v1/orders/#{path_segment(id)}/status", body: body) || {}
33
+ end
34
+
35
+ def status_history(id, params = {})
36
+ @http.request('GET', "/partner/v1/orders/#{path_segment(id)}/status-history", query: params) || {}
37
+ end
38
+
39
+ def line_items(id)
40
+ @http.request('GET', "/partner/v1/orders/#{path_segment(id)}/line-items") || {}
41
+ end
42
+
43
+ def contract(id)
44
+ @http.request('GET', "/partner/v1/orders/#{path_segment(id)}/contract") || {}
45
+ end
46
+
47
+ def payments(id, params = {})
48
+ @http.request('GET', "/partner/v1/orders/#{path_segment(id)}/payments", query: params) || {}
49
+ end
50
+
51
+ def create_payment(id, body, options: nil)
52
+ @http.request('POST', "/partner/v1/orders/#{path_segment(id)}/payments", body: body, headers: option_headers(options)) || {}
53
+ end
54
+
55
+ def create_payment_link(id, body)
56
+ @http.request('POST', "/partner/v1/orders/#{path_segment(id)}/payment-links", body: body) || {}
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Payments < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/payments', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/payments/#{path_segment(id)}") || {}
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Products < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/products', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/products/#{path_segment(id)}") || {}
13
+ end
14
+
15
+ def create(body, options: nil)
16
+ @http.request('POST', '/partner/v1/products', body: body, headers: option_headers(options)) || {}
17
+ end
18
+
19
+ def update(id, body)
20
+ @http.request('PATCH', "/partner/v1/products/#{path_segment(id)}", body: body) || {}
21
+ end
22
+
23
+ def create_size(id, body, options: nil)
24
+ @http.request('POST', "/partner/v1/products/#{path_segment(id)}/sizes", body: body, headers: option_headers(options)) || {}
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Quotes < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/quotes', query: params) || {}
9
+ end
10
+
11
+ def create(body, options: nil)
12
+ @http.request('POST', '/partner/v1/quotes', body: body, headers: option_headers(options)) || {}
13
+ end
14
+
15
+ def convert(id, body = {}, options: nil)
16
+ @http.request('POST', "/partner/v1/quotes/#{path_segment(id)}/convert", body: body, headers: option_headers(options)) || {}
17
+ end
18
+
19
+ def get(id)
20
+ @http.request('GET', "/partner/v1/quotes/#{path_segment(id)}") || {}
21
+ end
22
+
23
+ def update(id, body, options: nil)
24
+ @http.request('PATCH', "/partner/v1/quotes/#{path_segment(id)}", body: body, headers: option_headers(options)) || {}
25
+ end
26
+
27
+ def update_status(id, body)
28
+ @http.request('POST', "/partner/v1/quotes/#{path_segment(id)}/status", body: body) || {}
29
+ end
30
+
31
+ def status_history(id, params = {})
32
+ @http.request('GET', "/partner/v1/quotes/#{path_segment(id)}/status-history", query: params) || {}
33
+ end
34
+
35
+ def line_items(id)
36
+ @http.request('GET', "/partner/v1/quotes/#{path_segment(id)}/line-items") || {}
37
+ end
38
+
39
+ def add_line_item(id, body)
40
+ @http.request('POST', "/partner/v1/quotes/#{path_segment(id)}/line-items", body: body) || {}
41
+ end
42
+
43
+ def delete_line_item(id, line_id)
44
+ @http.request('DELETE', "/partner/v1/quotes/#{path_segment(id)}/line-items/#{path_segment(line_id)}")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class StockTemplates < Base
7
+ def list(params = {})
8
+ query = params.dup
9
+ query[:tags] = query[:tags].join(',') if query[:tags].is_a?(Array)
10
+ @http.request('GET', '/partner/v1/stock-templates', query: query) || {}
11
+ end
12
+
13
+ def get(id)
14
+ @http.request('GET', "/partner/v1/stock-templates/#{path_segment(id)}") || {}
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShedCloud
4
+ module PartnerApi
5
+ module Resources
6
+ class Users < Base
7
+ def list(params = {})
8
+ @http.request('GET', '/partner/v1/users', query: params) || {}
9
+ end
10
+
11
+ def get(id)
12
+ @http.request('GET', "/partner/v1/users/#{path_segment(id)}") || {}
13
+ end
14
+
15
+ def create(body, options: nil)
16
+ @http.request('POST', '/partner/v1/users', body: body, headers: option_headers(options)) || {}
17
+ end
18
+
19
+ def update(id, body)
20
+ @http.request('PATCH', "/partner/v1/users/#{path_segment(id)}", body: body) || {}
21
+ end
22
+
23
+ def roles
24
+ @http.request('GET', '/partner/v1/roles') || {}
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end