kiriminaja 1.0.0 → 1.0.3

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: 362409453e97df85b8dfc075814cb73ea173f96fd3bf8b4468725b3c85bdb463
4
- data.tar.gz: aa4ba1fb9a38da45aef06fc0e498552995382efd0378904c86b5f45ec46b519d
3
+ metadata.gz: 310f2dc37e8e014ca682e32a2bbbbd96073675dcaa78ca1126818932bec782b6
4
+ data.tar.gz: 81087fafb216e7e6df106c989936cec02cdf6f8c740e6219c1c30c27957f14ee
5
5
  SHA512:
6
- metadata.gz: d5f7cffea7c8d839dcc9bf2ae3d4edb0ce083b407b9452b63b8546a182e7baa0f6f65b147d16a7506383b32a621764106f55b24dc948026292168da19feedef5
7
- data.tar.gz: c97f455972851b158347fa1ff67e4df4647621666807019010940e403920929674f896067dea5262deae4305020597c277a42ac21bee6760d53081acb63493e0
6
+ metadata.gz: 6ec28f0546d8bb24c207d365d3bbc2e2925258c7f0d9dcc9c687144f47f6d219911b1812fbe2aeb71fbdac47e7a1b5d93a64b12515c0d2ffbfa815c80603ed4b
7
+ data.tar.gz: 106cab76b95896ba2e2c16e4ee855f2b281812157de98b1d3c7df7c118ce13b0cb6534991639de8cecfb2fea59a765821011a8da8905ba8b5900de1783b94d10
data/README.md CHANGED
@@ -168,6 +168,23 @@ client.order.express.request_pickup(
168
168
  cod: 0,
169
169
  package_type_id: 7,
170
170
  item_name: "TEST Item name",
171
+ # `items` is optional. When provided, it lists the individual
172
+ # items inside the package. `item_value` is still required.
173
+ items: [
174
+ KiriminAja::Types::RequestPickupItem.new(
175
+ name: "Kaos Polos",
176
+ price: 125000,
177
+ qty: 2,
178
+ weight: 260,
179
+ width: 4,
180
+ length: 4,
181
+ height: 4,
182
+ metadata: KiriminAja::Types::RequestPickupItemMetadata.new(
183
+ sku: "KP-001",
184
+ variant_label: "Merah / L",
185
+ ),
186
+ ),
187
+ ],
171
188
  ),
172
189
  ],
173
190
  )
@@ -242,6 +259,70 @@ client.courier.set_whitelist_services(["jne_reg", "jne_yes"])
242
259
 
243
260
  ---
244
261
 
262
+ ### Credit
263
+
264
+ ```ruby
265
+ # Get the current KiriminAja credit balance
266
+ client.credit.balance
267
+ ```
268
+
269
+ ---
270
+
271
+ ### AWB (Print Waybill)
272
+
273
+ ```ruby
274
+ # Print shipping label / waybill by AWB number(s)
275
+ client.awb.print({ awb: ["AWB123", "AWB456"] })
276
+ # response["data"]["data"]["url"] => PDF download URL
277
+ ```
278
+
279
+ ---
280
+
281
+ ### Calculations (COD)
282
+
283
+ ```ruby
284
+ # Calculate COD (Cash on Delivery) fee
285
+ client.calculations.cod({
286
+ item_price: 100000,
287
+ data: [
288
+ {
289
+ courier_code: "jne",
290
+ courier_service_code: "reg",
291
+ shipping_cost: 10000,
292
+ },
293
+ ],
294
+ })
295
+ # response["results"] => array of fee breakdown per courier/service
296
+ ```
297
+
298
+ ---
299
+
300
+ ### Profile
301
+
302
+ ```ruby
303
+ # Get member profile and metadata
304
+ client.profile.get
305
+ # response["results"]["id"], response["results"]["email"], etc.
306
+ ```
307
+
308
+ ---
309
+
310
+ ### Utilities — Volumetric
311
+
312
+ Estimate the smallest bounding box (length / width / height) for a
313
+ multi-item package by trying three stacking strategies and returning the
314
+ arrangement with the smallest volume.
315
+
316
+ ```ruby
317
+ dim = KiriminAja::Utils::Volumetric.calculate([
318
+ { qty: 2, length: 10, width: 10, height: 2 },
319
+ { qty: 1, length: 5, width: 5, height: 5 }
320
+ ])
321
+ # dim[:length], dim[:width], dim[:height]
322
+ ```
323
+
324
+ ---
325
+
245
326
  ### Pickup Schedules
246
327
 
247
328
  ```ruby
@@ -7,15 +7,19 @@ require_relative "types/enums"
7
7
  require_relative "types/address"
8
8
  require_relative "types/order"
9
9
  require_relative "services/address/address"
10
+ require_relative "services/awb/awb"
11
+ require_relative "services/calculations/calculations"
10
12
  require_relative "services/coverage_area/coverage_area"
11
13
  require_relative "services/courier/courier"
14
+ require_relative "services/credit/credit"
12
15
  require_relative "services/order/order"
13
16
  require_relative "services/payment/payment"
14
17
  require_relative "services/pickup/pickup"
18
+ require_relative "services/profile/profile"
15
19
 
16
20
  module KiriminAja
17
21
  class Client
18
- attr_reader :address, :coverage_area, :courier, :order, :payment, :pickup
22
+ attr_reader :address, :awb, :calculations, :coverage_area, :courier, :credit, :order, :payment, :pickup, :profile
19
23
 
20
24
  def initialize(env: Config::ENV_SANDBOX, api_key: nil, base_url: nil, http_client: nil)
21
25
  config = Config::ClientConfig.new(
@@ -27,11 +31,15 @@ module KiriminAja
27
31
  http = Http::Request.new(config)
28
32
 
29
33
  @address = Services::AddressService.new(http)
34
+ @awb = Services::AWBService.new(http)
35
+ @calculations = Services::CalculationsService.new(http)
30
36
  @coverage_area = Services::CoverageAreaService.new(http)
31
37
  @courier = Services::CourierService.new(http)
38
+ @credit = Services::CreditService.new(http)
32
39
  @order = Services::OrderService.new(http)
33
40
  @payment = Services::PaymentService.new(http)
34
41
  @pickup = Services::PickupService.new(http)
42
+ @profile = Services::ProfileService.new(http)
35
43
  end
36
44
  end
37
45
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class AWBService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def print(payload)
11
+ @http.post_json("/api/mitra/v6.1/awb/print", payload)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class CalculationsService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def cod(payload)
11
+ @http.post_json("/api/mitra/calculations/cod", payload)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class CreditService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def balance
11
+ @http.get_json("/api/mitra/v6.2/credit/balance")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class ProfileService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def get
11
+ @http.get_json("/api/mitra/v6.2/profile")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,20 +2,66 @@
2
2
 
3
3
  module KiriminAja
4
4
  module Types
5
+ class RequestPickupItemMetadata
6
+ attr_accessor :sku, :variant_label
7
+
8
+ def initialize(sku: nil, variant_label: nil)
9
+ @sku = sku
10
+ @variant_label = variant_label
11
+ end
12
+
13
+ def to_h
14
+ d = {}
15
+ d[:sku] = @sku unless @sku.nil?
16
+ d[:variant_label] = @variant_label unless @variant_label.nil?
17
+ d
18
+ end
19
+ end
20
+
21
+ class RequestPickupItem
22
+ attr_accessor :name, :price, :qty, :weight, :width, :length, :height, :metadata
23
+
24
+ def initialize(name:, price:, qty:, weight:,
25
+ width: nil, length: nil, height: nil, metadata: nil)
26
+ @name = name
27
+ @price = price
28
+ @qty = qty
29
+ @weight = weight
30
+ @width = width
31
+ @length = length
32
+ @height = height
33
+ @metadata = metadata
34
+ end
35
+
36
+ def to_h
37
+ d = {
38
+ name: @name,
39
+ price: @price,
40
+ qty: @qty,
41
+ weight: @weight,
42
+ }
43
+ d[:width] = @width unless @width.nil?
44
+ d[:length] = @length unless @length.nil?
45
+ d[:height] = @height unless @height.nil?
46
+ d[:metadata] = @metadata.to_h unless @metadata.nil?
47
+ d
48
+ end
49
+ end
50
+
5
51
  class RequestPickupPackage
6
52
  attr_accessor :order_id, :destination_name, :destination_phone, :destination_address,
7
53
  :destination_kecamatan_id, :weight, :width, :length, :height,
8
54
  :item_value, :shipping_cost, :service, :service_type, :cod,
9
55
  :package_type_id, :item_name,
10
56
  :destination_kelurahan_id, :destination_zipcode, :qty,
11
- :insurance_amount, :drop, :note
57
+ :insurance_amount, :drop, :note, :items
12
58
 
13
59
  def initialize(order_id:, destination_name:, destination_phone:, destination_address:,
14
60
  destination_kecamatan_id:, weight:, width:, length:, height:,
15
61
  item_value:, shipping_cost:, service:, service_type:, cod:,
16
62
  package_type_id:, item_name:,
17
63
  destination_kelurahan_id: nil, destination_zipcode: nil, qty: nil,
18
- insurance_amount: nil, drop: nil, note: nil)
64
+ insurance_amount: nil, drop: nil, note: nil, items: nil)
19
65
  @order_id = order_id
20
66
  @destination_name = destination_name
21
67
  @destination_phone = destination_phone
@@ -38,6 +84,7 @@ module KiriminAja
38
84
  @insurance_amount = insurance_amount
39
85
  @drop = drop
40
86
  @note = note
87
+ @items = items
41
88
  end
42
89
 
43
90
  def to_h
@@ -65,6 +112,7 @@ module KiriminAja
65
112
  d[:insurance_amount] = @insurance_amount unless @insurance_amount.nil?
66
113
  d[:drop] = @drop unless @drop.nil?
67
114
  d[:note] = @note unless @note.nil?
115
+ d[:items] = @items.map(&:to_h) unless @items.nil?
68
116
  d
69
117
  end
70
118
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Utils
5
+ module Volumetric
6
+ module_function
7
+
8
+ # Returns { length:, width:, height: } as the smallest bounding box
9
+ # across vertical / horizontal / side-by-side stacking strategies.
10
+ #
11
+ # Each item is a Hash with keys: :qty, :length, :width, :height
12
+ # (string keys are also accepted). Missing values default to 0; qty < 1
13
+ # is treated as 1.
14
+ def calculate(items)
15
+ return { length: 0, width: 0, height: 0 } if items.nil? || items.empty?
16
+
17
+ l_vert = w_vert = h_vert = 0
18
+ l_hor = w_hor = h_hor = 0
19
+ l_side = w_side = h_side = 0
20
+
21
+ items.each do |it|
22
+ qty = (fetch(it, :qty) || 1).to_i
23
+ qty = 1 if qty < 1
24
+ l = fetch(it, :length) || 0
25
+ w = fetch(it, :width) || 0
26
+ h = fetch(it, :height) || 0
27
+
28
+ h_vert += h * qty
29
+ l_vert = l if l > l_vert
30
+ w_vert = w if w > w_vert
31
+
32
+ l_hor += l * qty
33
+ h_hor = h if h > h_hor
34
+ w_hor = w if w > w_hor
35
+
36
+ w_side += w * qty
37
+ h_side = h if h > h_side
38
+ l_side = l if l > l_side
39
+ end
40
+
41
+ vol_vert = l_vert * w_vert * h_vert
42
+ vol_hor = l_hor * w_hor * h_hor
43
+ vol_side = l_side * w_side * h_side
44
+
45
+ if vol_vert <= vol_hor && vol_vert <= vol_side
46
+ { length: l_vert, width: w_vert, height: h_vert }
47
+ elsif vol_hor <= vol_side
48
+ { length: l_hor, width: w_hor, height: h_hor }
49
+ else
50
+ { length: l_side, width: w_side, height: h_side }
51
+ end
52
+ end
53
+
54
+ def fetch(item, key)
55
+ item[key] || item[key.to_s]
56
+ end
57
+ private_class_method :fetch
58
+ end
59
+ end
60
+ end
data/lib/kiriminaja.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "kiriminaja/client"
4
+ require_relative "kiriminaja/utils/volumetric"
4
5
 
5
6
  module KiriminAja
6
7
  VERSION = begin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiriminaja
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - KiriminAja Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-14 00:00:00.000000000 Z
11
+ date: 2026-06-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby SDK for the KiriminAja logistics API. Supports address lookup, coverage
14
14
  area pricing, order management (express & instant), courier services, pickup scheduling,
@@ -28,14 +28,19 @@ files:
28
28
  - lib/kiriminaja/config/client.rb
29
29
  - lib/kiriminaja/http/request.rb
30
30
  - lib/kiriminaja/services/address/address.rb
31
+ - lib/kiriminaja/services/awb/awb.rb
32
+ - lib/kiriminaja/services/calculations/calculations.rb
31
33
  - lib/kiriminaja/services/courier/courier.rb
32
34
  - lib/kiriminaja/services/coverage_area/coverage_area.rb
35
+ - lib/kiriminaja/services/credit/credit.rb
33
36
  - lib/kiriminaja/services/order/order.rb
34
37
  - lib/kiriminaja/services/payment/payment.rb
35
38
  - lib/kiriminaja/services/pickup/pickup.rb
39
+ - lib/kiriminaja/services/profile/profile.rb
36
40
  - lib/kiriminaja/types/address.rb
37
41
  - lib/kiriminaja/types/enums.rb
38
42
  - lib/kiriminaja/types/order.rb
43
+ - lib/kiriminaja/utils/volumetric.rb
39
44
  homepage: https://developer.kiriminaja.com
40
45
  licenses:
41
46
  - MIT