flexops 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de7a8ef21d6a80d52efbbb2f7254fb5184c875ab84a09834204d4757736040ce
4
- data.tar.gz: 741a555c559275fe53124fa44d5cd76d3d9dbf57031b12346dfecb63e9c26c73
3
+ metadata.gz: 46267de883ed8970bdcfc87d77c86edcf9b33a5d1ffe0d312a10961ea43646fb
4
+ data.tar.gz: 9c828d5d8fbc74b2b3abee2640b1742de692a800e51fe60f3fd671b728564dc6
5
5
  SHA512:
6
- metadata.gz: e32d5a2172b700037fe706867b7111a5f6af66d099bf8f759b916fb38134b7760a3212d2f44c6eec83a10b243cf602c2fadd20792884871fbdcc878b84306f8c
7
- data.tar.gz: 4446a9a607aba3ccc55b694f4438a63d6d20422825a7bd476da37dad4021885e60d2b93e65f6cf72ef65eb9ac4b930f2afd0a4fc26361a651f877be185ed6a7f
6
+ metadata.gz: 439f0b3d74903968585f2d980e80d00798f9784903100851804949a7602c3bc163f0ce3600e5602ebfe6fca0e85d93b64f2bc5b5269abfebd9eb573535db20b5
7
+ data.tar.gz: eff6ea869f9cfd93dca01e4bc9bfd794a64fb36f51825743ae7f0bef5783e8698b08324b976048b0a360622d6d49de9c355083fac6072007266080e5461aa874
data/README.md CHANGED
@@ -35,13 +35,13 @@ client = FlexOps::Client.new(
35
35
 
36
36
  # Get shipping rates from all carriers
37
37
  rates = client.shipping.get_rates(
38
- from_address: {street1: "123 Main St", city: "New York", state: "NY", zip: "10001", country: "US"},
39
- to_address: {street1: "456 Oak Ave", city: "Los Angeles", state: "CA", zip: "90210", country: "US"},
40
- parcel: {weight: 16, weight_unit: "oz"}
38
+ origin: {addressLine1: "123 Main St", city: "New York", stateProvince: "NY", postalCode: "10001"},
39
+ destination: {addressLine1: "456 Oak Ave", city: "Los Angeles", stateProvince: "CA", postalCode: "90210"},
40
+ package: {weight: 16, weightUnit: "oz"}
41
41
  )
42
42
 
43
43
  # Create a label with the cheapest rate
44
- cheapest = rates["data"].min_by { |r| r["totalCost"].to_f }
44
+ cheapest = rates["rates"].min_by { |r| r["rate"].to_f }
45
45
  label = client.shipping.create_label(
46
46
  carrier: cheapest["carrier"],
47
47
  service: cheapest["service"],
@@ -119,13 +119,13 @@ Every SDK method is a thin wrapper around the FlexOps REST API. If you want to v
119
119
 
120
120
  ```bash
121
121
  # Shop rates across all connected carriers
122
- curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/rates \
122
+ curl -X POST https://gateway.flexops.io/api/shipping/rates \
123
123
  -H "X-API-Key: fxk_live_..." \
124
124
  -H "Content-Type: application/json" \
125
125
  -d '{
126
- "fromAddress": {"street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
127
- "toAddress": {"street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
128
- "parcel": {"weight": 16, "weightUnit": "oz"}
126
+ "origin": {"addressLine1": "123 Main St", "city": "New York", "stateProvince": "NY", "postalCode": "10001", "countryCode": "US"},
127
+ "destination": {"addressLine1": "456 Oak Ave", "city": "Los Angeles", "stateProvince": "CA", "postalCode": "90210", "countryCode": "US"},
128
+ "package": {"weight": 16, "weightUnit": "oz"}
129
129
  }'
130
130
 
131
131
  # Create a label
@@ -193,4 +193,4 @@ client = FlexOps::Client.new(
193
193
 
194
194
  ## License
195
195
 
196
- Proprietary FlexOps, LLC
196
+ MIT © FlexOps, LLC. See [LICENSE](LICENSE) for full text.
@@ -1,35 +1,35 @@
1
- # ***********************************************************************
2
- # Package : flexops
3
- # Author : FlexOps, LLC
4
- # Created : 2026-03-08
5
- #
6
- # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
- # ***********************************************************************
8
-
9
- module FlexOps
10
- class Error < StandardError
11
- attr_reader :status, :code, :errors
12
-
13
- def initialize(message, status: 0, code: nil, errors: nil)
14
- super(message)
15
- @status = status
16
- @code = code
17
- @errors = errors
18
- end
19
- end
20
-
21
- class AuthError < Error
22
- def initialize(message = "Authentication required. Check your access token or API key.")
23
- super(message, status: 401, code: "UNAUTHORIZED")
24
- end
25
- end
26
-
27
- class RateLimitError < Error
28
- attr_reader :retry_after
29
-
30
- def initialize(retry_after: 0)
31
- super("Rate limited. Retry after #{retry_after}s", status: 429, code: "RATE_LIMITED")
32
- @retry_after = retry_after
33
- end
34
- end
35
- end
1
+ # ***********************************************************************
2
+ # Package : flexops
3
+ # Author : FlexOps, LLC
4
+ # Created : 2026-03-08
5
+ #
6
+ # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
+ # ***********************************************************************
8
+
9
+ module FlexOps
10
+ class Error < StandardError
11
+ attr_reader :status, :code, :errors
12
+
13
+ def initialize(message, status: 0, code: nil, errors: nil)
14
+ super(message)
15
+ @status = status
16
+ @code = code
17
+ @errors = errors
18
+ end
19
+ end
20
+
21
+ class AuthError < Error
22
+ def initialize(message = "Authentication required. Check your access token or API key.")
23
+ super(message, status: 401, code: "UNAUTHORIZED")
24
+ end
25
+ end
26
+
27
+ class RateLimitError < Error
28
+ attr_reader :retry_after
29
+
30
+ def initialize(retry_after: 0)
31
+ super("Rate limited. Retry after #{retry_after}s", status: 429, code: "RATE_LIMITED")
32
+ @retry_after = retry_after
33
+ end
34
+ end
35
+ end
@@ -1,85 +1,85 @@
1
- # ***********************************************************************
2
- # Package : flexops
3
- # Author : FlexOps, LLC
4
- # Created : 2026-03-08
5
- #
6
- # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
- # ***********************************************************************
8
-
9
- module FlexOps
10
- module Resources
11
- class Analytics
12
- BASE = "/api/ApiProxy/api/v4/Analytics"
13
-
14
- def initialize(http)
15
- @http = http
16
- end
17
-
18
- def shipments_trend(start_date: nil, end_date: nil)
19
- @http.get("#{BASE}/ShipmentsTrend", query: date_query(start_date, end_date))
20
- end
21
-
22
- def carrier_summary(start_date: nil, end_date: nil)
23
- @http.get("#{BASE}/CarrierSummary", query: date_query(start_date, end_date))
24
- end
25
-
26
- def top_destinations(start_date: nil, end_date: nil, limit: nil)
27
- @http.get("#{BASE}/TopDestinations", query: date_query(start_date, end_date).merge(limit: limit).compact)
28
- end
29
-
30
- def inventory_metrics
31
- @http.get("#{BASE}/InventoryMetrics")
32
- end
33
-
34
- def stock_by_warehouse
35
- @http.get("#{BASE}/StockByWarehouse")
36
- end
37
-
38
- def order_metrics(start_date: nil, end_date: nil)
39
- @http.get("#{BASE}/OrderMetrics", query: date_query(start_date, end_date))
40
- end
41
-
42
- def order_trend(start_date: nil, end_date: nil)
43
- @http.get("#{BASE}/OrderTrend", query: date_query(start_date, end_date))
44
- end
45
-
46
- def top_selling_products(start_date: nil, end_date: nil, limit: nil)
47
- @http.get("#{BASE}/TopSellingProducts", query: date_query(start_date, end_date).merge(limit: limit).compact)
48
- end
49
-
50
- def returns_metrics(start_date: nil, end_date: nil)
51
- @http.get("#{BASE}/ReturnsMetrics", query: date_query(start_date, end_date))
52
- end
53
-
54
- def returns_trend(start_date: nil, end_date: nil)
55
- @http.get("#{BASE}/ReturnsTrend", query: date_query(start_date, end_date))
56
- end
57
-
58
- def return_reasons(start_date: nil, end_date: nil)
59
- @http.get("#{BASE}/ReturnReasons", query: date_query(start_date, end_date))
60
- end
61
-
62
- def performance_metrics(start_date: nil, end_date: nil)
63
- @http.get("#{BASE}/PerformanceMetrics", query: date_query(start_date, end_date))
64
- end
65
-
66
- def carrier_performance(start_date: nil, end_date: nil)
67
- @http.get("#{BASE}/CarrierPerformance", query: date_query(start_date, end_date))
68
- end
69
-
70
- def shipping_cost_analytics(start_date: nil, end_date: nil)
71
- @http.get("#{BASE}/ShippingCostAnalytics", query: date_query(start_date, end_date))
72
- end
73
-
74
- def delivery_performance(start_date: nil, end_date: nil)
75
- @http.get("#{BASE}/DeliveryPerformance", query: date_query(start_date, end_date))
76
- end
77
-
78
- private
79
-
80
- def date_query(start_date, end_date)
81
- { startDate: start_date, endDate: end_date }.compact
82
- end
83
- end
84
- end
85
- end
1
+ # ***********************************************************************
2
+ # Package : flexops
3
+ # Author : FlexOps, LLC
4
+ # Created : 2026-03-08
5
+ #
6
+ # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
+ # ***********************************************************************
8
+
9
+ module FlexOps
10
+ module Resources
11
+ class Analytics
12
+ BASE = "/api/ApiProxy/api/v4/Analytics"
13
+
14
+ def initialize(http)
15
+ @http = http
16
+ end
17
+
18
+ def shipments_trend(start_date: nil, end_date: nil)
19
+ @http.get("#{BASE}/ShipmentsTrend", query: date_query(start_date, end_date))
20
+ end
21
+
22
+ def carrier_summary(start_date: nil, end_date: nil)
23
+ @http.get("#{BASE}/CarrierSummary", query: date_query(start_date, end_date))
24
+ end
25
+
26
+ def top_destinations(start_date: nil, end_date: nil, limit: nil)
27
+ @http.get("#{BASE}/TopDestinations", query: date_query(start_date, end_date).merge(limit: limit).compact)
28
+ end
29
+
30
+ def inventory_metrics
31
+ @http.get("#{BASE}/InventoryMetrics")
32
+ end
33
+
34
+ def stock_by_warehouse
35
+ @http.get("#{BASE}/StockByWarehouse")
36
+ end
37
+
38
+ def order_metrics(start_date: nil, end_date: nil)
39
+ @http.get("#{BASE}/OrderMetrics", query: date_query(start_date, end_date))
40
+ end
41
+
42
+ def order_trend(start_date: nil, end_date: nil)
43
+ @http.get("#{BASE}/OrderTrend", query: date_query(start_date, end_date))
44
+ end
45
+
46
+ def top_selling_products(start_date: nil, end_date: nil, limit: nil)
47
+ @http.get("#{BASE}/TopSellingProducts", query: date_query(start_date, end_date).merge(limit: limit).compact)
48
+ end
49
+
50
+ def returns_metrics(start_date: nil, end_date: nil)
51
+ @http.get("#{BASE}/ReturnsMetrics", query: date_query(start_date, end_date))
52
+ end
53
+
54
+ def returns_trend(start_date: nil, end_date: nil)
55
+ @http.get("#{BASE}/ReturnsTrend", query: date_query(start_date, end_date))
56
+ end
57
+
58
+ def return_reasons(start_date: nil, end_date: nil)
59
+ @http.get("#{BASE}/ReturnReasons", query: date_query(start_date, end_date))
60
+ end
61
+
62
+ def performance_metrics(start_date: nil, end_date: nil)
63
+ @http.get("#{BASE}/PerformanceMetrics", query: date_query(start_date, end_date))
64
+ end
65
+
66
+ def carrier_performance(start_date: nil, end_date: nil)
67
+ @http.get("#{BASE}/CarrierPerformance", query: date_query(start_date, end_date))
68
+ end
69
+
70
+ def shipping_cost_analytics(start_date: nil, end_date: nil)
71
+ @http.get("#{BASE}/ShippingCostAnalytics", query: date_query(start_date, end_date))
72
+ end
73
+
74
+ def delivery_performance(start_date: nil, end_date: nil)
75
+ @http.get("#{BASE}/DeliveryPerformance", query: date_query(start_date, end_date))
76
+ end
77
+
78
+ private
79
+
80
+ def date_query(start_date, end_date)
81
+ { startDate: start_date, endDate: end_date }.compact
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,40 +1,40 @@
1
- # ***********************************************************************
2
- # Package : flexops
3
- # Author : FlexOps, LLC
4
- # Created : 2026-03-08
5
- #
6
- # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
- # ***********************************************************************
8
-
9
- module FlexOps
10
- module Resources
11
- class ApiKeys
12
- def initialize(http, ws_id_proc)
13
- @http = http
14
- @ws_id = ws_id_proc
15
- end
16
-
17
- def list
18
- @http.get("#{ws_path}/api-keys")
19
- end
20
-
21
- def create(request)
22
- @http.post("#{ws_path}/api-keys", body: request)
23
- end
24
-
25
- def revoke(key_id)
26
- @http.delete("#{ws_path}/api-keys/#{key_id}")
27
- end
28
-
29
- def rotate(key_id)
30
- @http.post("#{ws_path}/api-keys/#{key_id}/rotate")
31
- end
32
-
33
- private
34
-
35
- def ws_path
36
- "/api/workspaces/#{@ws_id.call}"
37
- end
38
- end
39
- end
40
- end
1
+ # ***********************************************************************
2
+ # Package : flexops
3
+ # Author : FlexOps, LLC
4
+ # Created : 2026-03-08
5
+ #
6
+ # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
+ # ***********************************************************************
8
+
9
+ module FlexOps
10
+ module Resources
11
+ class ApiKeys
12
+ def initialize(http, ws_id_proc)
13
+ @http = http
14
+ @ws_id = ws_id_proc
15
+ end
16
+
17
+ def list
18
+ @http.get("#{ws_path}/api-keys")
19
+ end
20
+
21
+ def create(request)
22
+ @http.post("#{ws_path}/api-keys", body: request)
23
+ end
24
+
25
+ def revoke(key_id)
26
+ @http.delete("#{ws_path}/api-keys/#{key_id}")
27
+ end
28
+
29
+ def rotate(key_id)
30
+ @http.post("#{ws_path}/api-keys/#{key_id}/rotate")
31
+ end
32
+
33
+ private
34
+
35
+ def ws_path
36
+ "/api/workspaces/#{@ws_id.call}"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,57 +1,57 @@
1
- # ***********************************************************************
2
- # Package : flexops
3
- # Author : FlexOps, LLC
4
- # Created : 2026-03-08
5
- #
6
- # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
- # ***********************************************************************
8
-
9
- module FlexOps
10
- module Resources
11
- class Auth
12
- def initialize(http)
13
- @http = http
14
- end
15
-
16
- def login(email:, password:)
17
- @http.post("/api/Account/login", body: { email: email, password: password })
18
- end
19
-
20
- def register(request)
21
- @http.post("/api/Account/register", body: request)
22
- end
23
-
24
- def refresh_token(refresh_token)
25
- @http.post("/api/Account/refresh-token", body: { refreshToken: refresh_token })
26
- end
27
-
28
- def logout
29
- @http.post("/api/Account/logout")
30
- end
31
-
32
- def get_profile
33
- @http.get("/api/Account/profile")
34
- end
35
-
36
- def update_profile(data)
37
- @http.put("/api/Account/profile", body: data)
38
- end
39
-
40
- def change_password(current_password:, new_password:)
41
- @http.post("/api/Account/change-password", body: { currentPassword: current_password, newPassword: new_password })
42
- end
43
-
44
- def forgot_password(email:)
45
- @http.post("/api/Account/forgot-password", body: { email: email })
46
- end
47
-
48
- def reset_password(token:, new_password:)
49
- @http.post("/api/Account/reset-password", body: { token: token, newPassword: new_password })
50
- end
51
-
52
- def verify_email(token:)
53
- @http.post("/api/Account/verify-email", body: { token: token })
54
- end
55
- end
56
- end
57
- end
1
+ # ***********************************************************************
2
+ # Package : flexops
3
+ # Author : FlexOps, LLC
4
+ # Created : 2026-03-08
5
+ #
6
+ # Copyright (c) 2021-2026 by FlexOps, LLC. All rights reserved.
7
+ # ***********************************************************************
8
+
9
+ module FlexOps
10
+ module Resources
11
+ class Auth
12
+ def initialize(http)
13
+ @http = http
14
+ end
15
+
16
+ def login(email:, password:)
17
+ @http.post("/api/Account/login", body: { email: email, password: password })
18
+ end
19
+
20
+ def register(request)
21
+ @http.post("/api/Account/register", body: request)
22
+ end
23
+
24
+ def refresh_token(refresh_token)
25
+ @http.post("/api/Account/refresh-token", body: { refreshToken: refresh_token })
26
+ end
27
+
28
+ def logout
29
+ @http.post("/api/Account/logout")
30
+ end
31
+
32
+ def get_profile
33
+ @http.get("/api/Account/profile")
34
+ end
35
+
36
+ def update_profile(data)
37
+ @http.put("/api/Account/profile", body: data)
38
+ end
39
+
40
+ def change_password(current_password:, new_password:)
41
+ @http.post("/api/Account/change-password", body: { currentPassword: current_password, newPassword: new_password })
42
+ end
43
+
44
+ def forgot_password(email:)
45
+ @http.post("/api/Account/forgot-password", body: { email: email })
46
+ end
47
+
48
+ def reset_password(token:, new_password:)
49
+ @http.post("/api/Account/reset-password", body: { token: token, newPassword: new_password })
50
+ end
51
+
52
+ def verify_email(token:)
53
+ @http.post("/api/Account/verify-email", body: { token: token })
54
+ end
55
+ end
56
+ end
57
+ end