kiriminaja 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d1fa5f3a4c002f0fdebdca0fc1e0be2ad3934fb614361ffc3873376ebe535a9e
4
+ data.tar.gz: 972ea7fbbd43aa721af1cae888f18416555f88352ea2d52e7eb6937ddad02563
5
+ SHA512:
6
+ metadata.gz: 2314e29e15e5ffc344e625c8c74d3dbe2d5f79ffcfa5061d6f7ab13f1bae86adc51981d88c90a4045a4ab21585758a0122c1d782f0e430e65ea10d17596f0fdf
7
+ data.tar.gz: 9fb494f39d287418ef7960ff3098186786b58eaaddaedf02a4803ca64c0861ec73045dd506a3d52767f205fce8045c9d00b55918adf0d51d129afefb38b0872e
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ .
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KiriminAja
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,306 @@
1
+ # KiriminAja Ruby SDK
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/kiriminaja)](https://rubygems.org/gems/kiriminaja)
4
+ [![license](https://img.shields.io/github/license/kiriminaja/ruby)](LICENSE)
5
+
6
+ Official Ruby SDK for the [KiriminAja](https://kiriminaja.com) logistics API. Zero external dependencies — uses only Ruby's standard library (`net/http`, `json`).
7
+
8
+ ## Requirements
9
+
10
+ - Ruby 3.0+
11
+
12
+ ## Installation
13
+
14
+ Add to your Gemfile:
15
+
16
+ ```ruby
17
+ gem "kiriminaja"
18
+ ```
19
+
20
+ Or install directly:
21
+
22
+ ```bash
23
+ gem install kiriminaja
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ Create a client with your API key, then call any service method.
31
+
32
+ ```ruby
33
+ require "kiriminaja"
34
+
35
+ client = KiriminAja::Client.new(
36
+ env: KiriminAja::Config::ENV_SANDBOX, # or ENV_PRODUCTION
37
+ api_key: ENV["KIRIMINAJA_API_KEY"],
38
+ )
39
+
40
+ # Use any service
41
+ provinces = client.address.provinces
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Config Options
47
+
48
+ | Option | Type | Default | Description |
49
+ | ------------- | ---------- | ------------------ | -------------------------------------- |
50
+ | `env` | `String` | `ENV_SANDBOX` | Target environment |
51
+ | `api_key` | `String` | — | Your KiriminAja API key |
52
+ | `base_url` | `String` | Derived from `env` | Override the base URL |
53
+ | `http_client` | duck-typed | auto-created | Custom HTTP client (proxy / test mock) |
54
+
55
+ ```ruby
56
+ # Custom base URL
57
+ client = KiriminAja::Client.new(
58
+ base_url: "https://tdev.kiriminaja.com",
59
+ api_key: ENV["KIRIMINAJA_API_KEY"],
60
+ )
61
+
62
+ # Custom HTTP client (e.g. with a specific timeout)
63
+ require "net/http"
64
+
65
+ http = Net::HTTP.new("tdev.kiriminaja.com", 443)
66
+ http.use_ssl = true
67
+ http.open_timeout = 10
68
+ http.read_timeout = 10
69
+
70
+ client = KiriminAja::Client.new(
71
+ api_key: "...",
72
+ http_client: http,
73
+ )
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Services
79
+
80
+ ### Address
81
+
82
+ ```ruby
83
+ # List all provinces
84
+ client.address.provinces
85
+
86
+ # Cities in a province (provinsi_id)
87
+ client.address.cities(5)
88
+
89
+ # Districts in a city (kabupaten_id)
90
+ client.address.districts(12)
91
+
92
+ # Sub-districts in a district (kecamatan_id)
93
+ client.address.sub_districts(77)
94
+
95
+ # Search districts by name
96
+ client.address.districts_by_name("jakarta")
97
+ ```
98
+
99
+ ---
100
+
101
+ ### Coverage Area & Pricing
102
+
103
+ ```ruby
104
+ # Express shipping rates
105
+ client.coverage_area.pricing_express(
106
+ KiriminAja::Types::PricingExpressPayload.new(
107
+ origin: 1,
108
+ destination: 2,
109
+ weight: 1000, # grams
110
+ item_value: 50000,
111
+ insurance: 0,
112
+ courier: ["jne", "jnt"],
113
+ )
114
+ )
115
+
116
+ # Instant (same-day) rates
117
+ client.coverage_area.pricing_instant(
118
+ KiriminAja::Types::PricingInstantPayload.new(
119
+ service: [KiriminAja::Types::InstantService::GOSEND],
120
+ item_price: 10000,
121
+ origin: KiriminAja::Types::PricingInstantLocationPayload.new(
122
+ lat: -6.2, long: 106.8, address: "Jl. Sudirman No.1",
123
+ ),
124
+ destination: KiriminAja::Types::PricingInstantLocationPayload.new(
125
+ lat: -6.21, long: 106.81, address: "Jl. Thamrin No.5",
126
+ ),
127
+ weight: 1000,
128
+ vehicle: KiriminAja::Types::InstantVehicle::BIKE,
129
+ timezone: "Asia/Jakarta",
130
+ )
131
+ )
132
+ ```
133
+
134
+ ---
135
+
136
+ ### Order — Express
137
+
138
+ ```ruby
139
+ # Track by order ID
140
+ client.order.express.track("ORDER123")
141
+
142
+ # Cancel by AWB
143
+ client.order.express.cancel("AWB123456", "Customer request")
144
+
145
+ # Request pickup
146
+ client.order.express.request_pickup(
147
+ KiriminAja::Types::RequestPickupPayload.new(
148
+ address: "Jl. Jodipati No.29",
149
+ phone: "08133345678",
150
+ name: "Tokotries",
151
+ kecamatan_id: 548,
152
+ schedule: "2021-11-30 22:00:00",
153
+ packages: [
154
+ KiriminAja::Types::RequestPickupPackage.new(
155
+ order_id: "YGL-000000019",
156
+ destination_name: "Flag Test",
157
+ destination_phone: "082223323333",
158
+ destination_address: "Jl. Magelang KM 11",
159
+ destination_kecamatan_id: 548,
160
+ weight: 520,
161
+ width: 8,
162
+ length: 8,
163
+ height: 8,
164
+ item_value: 275000,
165
+ shipping_cost: 65000,
166
+ service: "jne",
167
+ service_type: "REG23",
168
+ cod: 0,
169
+ package_type_id: 7,
170
+ item_name: "TEST Item name",
171
+ ),
172
+ ],
173
+ )
174
+ )
175
+ ```
176
+
177
+ ---
178
+
179
+ ### Order — Instant
180
+
181
+ ```ruby
182
+ # Create instant pickup
183
+ client.order.instant.create(
184
+ KiriminAja::Types::InstantPickupPayload.new(
185
+ service: KiriminAja::Types::InstantService::GOSEND,
186
+ service_type: "instant",
187
+ vehicle: KiriminAja::Types::InstantVehicle::BIKE,
188
+ order_prefix: "BDI",
189
+ packages: [
190
+ KiriminAja::Types::InstantPickupPackage.new(
191
+ origin_name: "Rizky",
192
+ origin_phone: "081280045616",
193
+ origin_lat: -7.854584,
194
+ origin_long: 110.331154,
195
+ origin_address: "Wirobrajan, Yogyakarta",
196
+ origin_address_note: "Dekat Kantor",
197
+ destination_name: "Okka",
198
+ destination_phone: "081280045616",
199
+ destination_lat: -7.776192,
200
+ destination_long: 110.325053,
201
+ destination_address: "Godean, Sleman",
202
+ destination_address_note: "Dekat Pasar",
203
+ shipping_price: 34000,
204
+ item: KiriminAja::Types::InstantPickupItem.new(
205
+ name: "Barang 1",
206
+ description: "Barang 1 Description",
207
+ price: 20000,
208
+ weight: 1000,
209
+ ),
210
+ ),
211
+ ],
212
+ )
213
+ )
214
+
215
+ # Find a new driver for an existing order
216
+ client.order.instant.find_new_driver("ORDER123")
217
+
218
+ # Cancel instant order
219
+ client.order.instant.cancel("ORDER123")
220
+
221
+ # Track instant order
222
+ client.order.instant.track("ORDER123")
223
+ ```
224
+
225
+ ---
226
+
227
+ ### Courier
228
+
229
+ ```ruby
230
+ # List available couriers
231
+ client.courier.list
232
+
233
+ # Courier groups
234
+ client.courier.group
235
+
236
+ # Courier service detail
237
+ client.courier.detail("jne")
238
+
239
+ # Set whitelist services
240
+ client.courier.set_whitelist_services(["jne_reg", "jne_yes"])
241
+ ```
242
+
243
+ ---
244
+
245
+ ### Pickup Schedules
246
+
247
+ ```ruby
248
+ client.pickup.schedules
249
+ ```
250
+
251
+ ---
252
+
253
+ ### Payment
254
+
255
+ ```ruby
256
+ client.payment.get_payment("PAY123")
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Rails Integration
262
+
263
+ The SDK works seamlessly in any Ruby application, including Rails.
264
+
265
+ ### Initializer
266
+
267
+ ```ruby
268
+ # config/initializers/kiriminaja.rb
269
+ KIRIMINAJA = KiriminAja::Client.new(
270
+ env: KiriminAja::Config::ENV_PRODUCTION,
271
+ api_key: Rails.application.credentials.kiriminaja_api_key,
272
+ )
273
+ ```
274
+
275
+ ### Controller usage
276
+
277
+ ```ruby
278
+ class ShippingController < ApplicationController
279
+ def rates
280
+ result = KIRIMINAJA.coverage_area.pricing_express(
281
+ KiriminAja::Types::PricingExpressPayload.new(
282
+ origin: params[:origin].to_i,
283
+ destination: params[:destination].to_i,
284
+ weight: params[:weight].to_i,
285
+ item_value: params[:item_value].to_i,
286
+ insurance: 0,
287
+ courier: params[:courier],
288
+ )
289
+ )
290
+ render json: result
291
+ end
292
+ end
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Contributing
298
+
299
+ For any requests, bugs, or comments, please open an [issue](https://github.com/kiriminaja/ruby/issues) or [submit a pull request](https://github.com/kiriminaja/ruby/pulls).
300
+
301
+ ## Development
302
+
303
+ ```bash
304
+ bundle install # install dependencies
305
+ bundle exec rake # run tests
306
+ ```
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "config/api"
4
+ require_relative "config/client"
5
+ require_relative "http/request"
6
+ require_relative "types/enums"
7
+ require_relative "types/address"
8
+ require_relative "types/order"
9
+ require_relative "services/address/address"
10
+ require_relative "services/coverage_area/coverage_area"
11
+ require_relative "services/courier/courier"
12
+ require_relative "services/order/order"
13
+ require_relative "services/payment/payment"
14
+ require_relative "services/pickup/pickup"
15
+
16
+ module KiriminAja
17
+ class Client
18
+ attr_reader :address, :coverage_area, :courier, :order, :payment, :pickup
19
+
20
+ def initialize(env: Config::ENV_SANDBOX, api_key: nil, base_url: nil, http_client: nil)
21
+ config = Config::ClientConfig.new(
22
+ env: env,
23
+ api_key: api_key,
24
+ base_url: base_url,
25
+ http_client: http_client,
26
+ )
27
+ http = Http::Request.new(config)
28
+
29
+ @address = Services::AddressService.new(http)
30
+ @coverage_area = Services::CoverageAreaService.new(http)
31
+ @courier = Services::CourierService.new(http)
32
+ @order = Services::OrderService.new(http)
33
+ @payment = Services::PaymentService.new(http)
34
+ @pickup = Services::PickupService.new(http)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Config
5
+ ENV_SANDBOX = "sandbox"
6
+ ENV_PRODUCTION = "production"
7
+
8
+ KA_ENV_URL = {
9
+ ENV_SANDBOX => "https://tdev.kiriminaja.com",
10
+ ENV_PRODUCTION => "https://client.kiriminaja.com",
11
+ }.freeze
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "api"
4
+
5
+ module KiriminAja
6
+ module Config
7
+ class ClientConfig
8
+ attr_reader :env, :base_url, :api_key, :http_client
9
+
10
+ def initialize(env: ENV_SANDBOX, api_key: nil, base_url: nil, http_client: nil)
11
+ @env = env
12
+ @api_key = api_key
13
+ @base_url = base_url || KA_ENV_URL.fetch(env, KA_ENV_URL[ENV_SANDBOX])
14
+ @http_client = http_client
15
+ end
16
+
17
+ def resolved_base_url
18
+ @base_url.chomp("/")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "uri"
5
+ require "json"
6
+
7
+ module KiriminAja
8
+ module Http
9
+ class Request
10
+ def initialize(config)
11
+ @config = config
12
+ end
13
+
14
+ def request_json(path, method: "POST", body: nil, query: nil, headers: nil)
15
+ url = build_url(path, query)
16
+ uri = URI.parse(url)
17
+
18
+ http = @config.http_client || build_http(uri)
19
+ req = build_request(uri, method, body, headers)
20
+
21
+ response = http.request(req)
22
+
23
+ unless response.is_a?(Net::HTTPSuccess)
24
+ raise "Request failed: #{response.code} #{response.message}"
25
+ end
26
+
27
+ JSON.parse(response.body)
28
+ end
29
+
30
+ def post_json(path, body = nil)
31
+ request_json(path, method: "POST", body: body)
32
+ end
33
+
34
+ def get_json(path)
35
+ request_json(path, method: "GET")
36
+ end
37
+
38
+ def delete_json(path)
39
+ request_json(path, method: "DELETE")
40
+ end
41
+
42
+ private
43
+
44
+ def build_url(path, query)
45
+ base = @config.resolved_base_url
46
+ normalized_path = path.start_with?("/") ? path : "/#{path}"
47
+ url = "#{base}#{normalized_path}"
48
+ if query && !query.empty?
49
+ params = URI.encode_www_form(query)
50
+ url += "?#{params}"
51
+ end
52
+ url
53
+ end
54
+
55
+ def build_http(uri)
56
+ http = Net::HTTP.new(uri.host, uri.port)
57
+ http.use_ssl = uri.scheme == "https"
58
+ http
59
+ end
60
+
61
+ def build_request(uri, method, body, extra_headers)
62
+ klass = case method.upcase
63
+ when "GET" then Net::HTTP::Get
64
+ when "POST" then Net::HTTP::Post
65
+ when "DELETE" then Net::HTTP::Delete
66
+ else raise ArgumentError, "Unsupported HTTP method: #{method}"
67
+ end
68
+
69
+ req = klass.new(uri)
70
+ req["Accept"] = "application/json"
71
+
72
+ if body && !%w[GET DELETE].include?(method.upcase)
73
+ req["Content-Type"] = "application/json"
74
+ req.body = JSON.generate(body)
75
+ end
76
+
77
+ if @config.api_key
78
+ req["Authorization"] = "Bearer #{@config.api_key}"
79
+ end
80
+
81
+ if extra_headers
82
+ extra_headers.each { |k, v| req[k] = v }
83
+ end
84
+
85
+ req
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class AddressService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def provinces
11
+ @http.post_json("/api/mitra/province")
12
+ end
13
+
14
+ def cities(provinsi_id)
15
+ @http.post_json("/api/mitra/city", { provinsi_id: provinsi_id })
16
+ end
17
+
18
+ def districts(kabupaten_id)
19
+ @http.post_json("/api/mitra/kecamatan", { kabupaten_id: kabupaten_id })
20
+ end
21
+
22
+ def sub_districts(kecamatan_id)
23
+ @http.post_json("/api/mitra/kelurahan", { kecamatan_id: kecamatan_id })
24
+ end
25
+
26
+ def districts_by_name(search)
27
+ @http.post_json("/api/mitra/v2/get_address_by_name", { search: search })
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class CourierService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def list
11
+ @http.post_json("/api/mitra/couriers")
12
+ end
13
+
14
+ def group
15
+ @http.post_json("/api/mitra/couriers_group")
16
+ end
17
+
18
+ def detail(courier_code)
19
+ @http.post_json("/api/mitra/courier_services", { courier_code: courier_code })
20
+ end
21
+
22
+ def set_whitelist_services(services)
23
+ @http.post_json("/api/mitra/v3/set_whitelist_services", { services: services })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class CoverageAreaService < AddressService
6
+ def pricing_express(payload)
7
+ @http.post_json("/api/mitra/v6.1/shipping_price", payload.to_h)
8
+ end
9
+
10
+ def pricing_instant(payload)
11
+ @http.post_json("/api/mitra/v4/instant/pricing", payload.to_h)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class ExpressOrderService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def track(order_id)
11
+ @http.post_json("/api/mitra/tracking", { order_id: order_id })
12
+ end
13
+
14
+ def cancel(awb, reason)
15
+ @http.request_json(
16
+ "/api/mitra/v3/cancel_shipment",
17
+ method: "POST",
18
+ query: { "awb" => awb, "reason" => reason }
19
+ )
20
+ end
21
+
22
+ def request_pickup(payload)
23
+ @http.post_json("/api/mitra/v6.1/request_pickup", payload.to_h)
24
+ end
25
+ end
26
+
27
+ class InstantOrderService
28
+ def initialize(http)
29
+ @http = http
30
+ end
31
+
32
+ def create(payload)
33
+ @http.post_json("/api/mitra/v4/instant/pickup/request", payload.to_h)
34
+ end
35
+
36
+ def track(order_id)
37
+ @http.get_json("/api/mitra/v4/instant/tracking/#{order_id}")
38
+ end
39
+
40
+ def cancel(order_id)
41
+ @http.delete_json("/api/mitra/v4/instant/pickup/void/#{order_id}")
42
+ end
43
+
44
+ def find_new_driver(order_id)
45
+ @http.post_json("/api/mitra/v4/instant/pickup/find-new-driver", { order_id: order_id })
46
+ end
47
+ end
48
+
49
+ class OrderService
50
+ attr_reader :express, :instant
51
+
52
+ def initialize(http)
53
+ @express = ExpressOrderService.new(http)
54
+ @instant = InstantOrderService.new(http)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Services
5
+ class PaymentService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def get_payment(payment_id)
11
+ @http.post_json("/api/mitra/v2/get_payment", { payment_id: payment_id })
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 PickupService
6
+ def initialize(http)
7
+ @http = http
8
+ end
9
+
10
+ def schedules
11
+ @http.post_json("/api/mitra/v2/schedules")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Types
5
+ class PricingExpressPayload
6
+ attr_accessor :origin, :destination, :weight, :item_value, :insurance, :courier
7
+
8
+ def initialize(origin:, destination:, weight:, item_value:, insurance:, courier:)
9
+ @origin = origin
10
+ @destination = destination
11
+ @weight = weight
12
+ @item_value = item_value
13
+ @insurance = insurance
14
+ @courier = courier
15
+ end
16
+
17
+ def to_h
18
+ {
19
+ origin: @origin,
20
+ destination: @destination,
21
+ weight: @weight,
22
+ item_value: @item_value,
23
+ insurance: @insurance,
24
+ courier: @courier,
25
+ }
26
+ end
27
+ end
28
+
29
+ class PricingInstantLocationPayload
30
+ attr_accessor :lat, :long, :address
31
+
32
+ def initialize(lat:, long:, address:)
33
+ @lat = lat
34
+ @long = long
35
+ @address = address
36
+ end
37
+
38
+ def to_h
39
+ { lat: @lat, long: @long, address: @address }
40
+ end
41
+ end
42
+
43
+ class PricingInstantPayload
44
+ attr_accessor :service, :item_price, :origin, :destination, :weight, :vehicle, :timezone
45
+
46
+ def initialize(service:, item_price:, origin:, destination:, weight:, vehicle:, timezone:)
47
+ @service = service
48
+ @item_price = item_price
49
+ @origin = origin
50
+ @destination = destination
51
+ @weight = weight
52
+ @vehicle = vehicle
53
+ @timezone = timezone
54
+ end
55
+
56
+ def to_h
57
+ {
58
+ service: Array(@service),
59
+ item_price: @item_price,
60
+ origin: @origin.to_h,
61
+ destination: @destination.to_h,
62
+ weight: @weight,
63
+ vehicle: @vehicle.to_s,
64
+ timezone: @timezone,
65
+ }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Types
5
+ module InstantService
6
+ GRAB_EXPRESS = "grab_express"
7
+ GOSEND = "gosend"
8
+ BORZO = "borzo"
9
+ end
10
+
11
+ module InstantVehicle
12
+ BIKE = "motor"
13
+ CAR = "mobil"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,199 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KiriminAja
4
+ module Types
5
+ class RequestPickupPackage
6
+ attr_accessor :order_id, :destination_name, :destination_phone, :destination_address,
7
+ :destination_kecamatan_id, :weight, :width, :length, :height,
8
+ :item_value, :shipping_cost, :service, :service_type, :cod,
9
+ :package_type_id, :item_name,
10
+ :destination_kelurahan_id, :destination_zipcode, :qty,
11
+ :insurance_amount, :drop, :note
12
+
13
+ def initialize(order_id:, destination_name:, destination_phone:, destination_address:,
14
+ destination_kecamatan_id:, weight:, width:, length:, height:,
15
+ item_value:, shipping_cost:, service:, service_type:, cod:,
16
+ package_type_id:, item_name:,
17
+ destination_kelurahan_id: nil, destination_zipcode: nil, qty: nil,
18
+ insurance_amount: nil, drop: nil, note: nil)
19
+ @order_id = order_id
20
+ @destination_name = destination_name
21
+ @destination_phone = destination_phone
22
+ @destination_address = destination_address
23
+ @destination_kecamatan_id = destination_kecamatan_id
24
+ @weight = weight
25
+ @width = width
26
+ @length = length
27
+ @height = height
28
+ @item_value = item_value
29
+ @shipping_cost = shipping_cost
30
+ @service = service
31
+ @service_type = service_type
32
+ @cod = cod
33
+ @package_type_id = package_type_id
34
+ @item_name = item_name
35
+ @destination_kelurahan_id = destination_kelurahan_id
36
+ @destination_zipcode = destination_zipcode
37
+ @qty = qty
38
+ @insurance_amount = insurance_amount
39
+ @drop = drop
40
+ @note = note
41
+ end
42
+
43
+ def to_h
44
+ d = {
45
+ order_id: @order_id,
46
+ destination_name: @destination_name,
47
+ destination_phone: @destination_phone,
48
+ destination_address: @destination_address,
49
+ destination_kecamatan_id: @destination_kecamatan_id,
50
+ weight: @weight,
51
+ width: @width,
52
+ length: @length,
53
+ height: @height,
54
+ item_value: @item_value,
55
+ shipping_cost: @shipping_cost,
56
+ service: @service,
57
+ service_type: @service_type,
58
+ cod: @cod,
59
+ package_type_id: @package_type_id,
60
+ item_name: @item_name,
61
+ }
62
+ d[:destination_kelurahan_id] = @destination_kelurahan_id unless @destination_kelurahan_id.nil?
63
+ d[:destination_zipcode] = @destination_zipcode unless @destination_zipcode.nil?
64
+ d[:qty] = @qty unless @qty.nil?
65
+ d[:insurance_amount] = @insurance_amount unless @insurance_amount.nil?
66
+ d[:drop] = @drop unless @drop.nil?
67
+ d[:note] = @note unless @note.nil?
68
+ d
69
+ end
70
+ end
71
+
72
+ class RequestPickupPayload
73
+ attr_accessor :address, :phone, :name, :kecamatan_id, :packages, :schedule,
74
+ :zipcode, :kelurahan_id, :latitude, :longitude, :platform_name
75
+
76
+ def initialize(address:, phone:, name:, kecamatan_id:, packages:, schedule:,
77
+ zipcode: nil, kelurahan_id: nil, latitude: nil, longitude: nil, platform_name: nil)
78
+ @address = address
79
+ @phone = phone
80
+ @name = name
81
+ @kecamatan_id = kecamatan_id
82
+ @packages = packages
83
+ @schedule = schedule
84
+ @zipcode = zipcode
85
+ @kelurahan_id = kelurahan_id
86
+ @latitude = latitude
87
+ @longitude = longitude
88
+ @platform_name = platform_name
89
+ end
90
+
91
+ def to_h
92
+ d = {
93
+ address: @address,
94
+ phone: @phone,
95
+ name: @name,
96
+ kecamatan_id: @kecamatan_id,
97
+ packages: @packages.map(&:to_h),
98
+ schedule: @schedule,
99
+ }
100
+ d[:zipcode] = @zipcode unless @zipcode.nil?
101
+ d[:kelurahan_id] = @kelurahan_id unless @kelurahan_id.nil?
102
+ d[:latitude] = @latitude unless @latitude.nil?
103
+ d[:longitude] = @longitude unless @longitude.nil?
104
+ d[:platform_name] = @platform_name unless @platform_name.nil?
105
+ d
106
+ end
107
+ end
108
+
109
+ class InstantPickupItem
110
+ attr_accessor :name, :description, :price, :weight
111
+
112
+ def initialize(name:, description:, price:, weight:)
113
+ @name = name
114
+ @description = description
115
+ @price = price
116
+ @weight = weight
117
+ end
118
+
119
+ def to_h
120
+ {
121
+ name: @name,
122
+ description: @description,
123
+ price: @price,
124
+ weight: @weight,
125
+ }
126
+ end
127
+ end
128
+
129
+ class InstantPickupPackage
130
+ attr_accessor :origin_name, :origin_phone, :origin_lat, :origin_long,
131
+ :origin_address, :origin_address_note,
132
+ :destination_name, :destination_phone, :destination_lat, :destination_long,
133
+ :destination_address, :destination_address_note,
134
+ :shipping_price, :item
135
+
136
+ def initialize(origin_name:, origin_phone:, origin_lat:, origin_long:,
137
+ origin_address:, origin_address_note:,
138
+ destination_name:, destination_phone:, destination_lat:, destination_long:,
139
+ destination_address:, destination_address_note:,
140
+ shipping_price:, item:)
141
+ @origin_name = origin_name
142
+ @origin_phone = origin_phone
143
+ @origin_lat = origin_lat
144
+ @origin_long = origin_long
145
+ @origin_address = origin_address
146
+ @origin_address_note = origin_address_note
147
+ @destination_name = destination_name
148
+ @destination_phone = destination_phone
149
+ @destination_lat = destination_lat
150
+ @destination_long = destination_long
151
+ @destination_address = destination_address
152
+ @destination_address_note = destination_address_note
153
+ @shipping_price = shipping_price
154
+ @item = item
155
+ end
156
+
157
+ def to_h
158
+ {
159
+ origin_name: @origin_name,
160
+ origin_phone: @origin_phone,
161
+ origin_lat: @origin_lat,
162
+ origin_long: @origin_long,
163
+ origin_address: @origin_address,
164
+ origin_address_note: @origin_address_note,
165
+ destination_name: @destination_name,
166
+ destination_phone: @destination_phone,
167
+ destination_lat: @destination_lat,
168
+ destination_long: @destination_long,
169
+ destination_address: @destination_address,
170
+ destination_address_note: @destination_address_note,
171
+ shipping_price: @shipping_price,
172
+ item: @item.to_h,
173
+ }
174
+ end
175
+ end
176
+
177
+ class InstantPickupPayload
178
+ attr_accessor :service, :service_type, :vehicle, :order_prefix, :packages
179
+
180
+ def initialize(service:, service_type:, vehicle:, order_prefix:, packages:)
181
+ @service = service
182
+ @service_type = service_type
183
+ @vehicle = vehicle
184
+ @order_prefix = order_prefix
185
+ @packages = packages
186
+ end
187
+
188
+ def to_h
189
+ {
190
+ service: @service.to_s,
191
+ service_type: @service_type,
192
+ vehicle: @vehicle.to_s,
193
+ order_prefix: @order_prefix,
194
+ packages: @packages.map(&:to_h),
195
+ }
196
+ end
197
+ end
198
+ end
199
+ end
data/lib/kiriminaja.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "kiriminaja/client"
4
+
5
+ module KiriminAja
6
+ VERSION = "0.1.0"
7
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kiriminaja
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - KiriminAja Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-04-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby SDK for the KiriminAja logistics API. Supports address lookup, coverage
14
+ area pricing, order management (express & instant), courier services, pickup scheduling,
15
+ and payments.
16
+ email:
17
+ - tech@kiriminaja.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - CODE_OF_CONDUCT.md
23
+ - LICENSE
24
+ - README.md
25
+ - lib/kiriminaja.rb
26
+ - lib/kiriminaja/client.rb
27
+ - lib/kiriminaja/config/api.rb
28
+ - lib/kiriminaja/config/client.rb
29
+ - lib/kiriminaja/http/request.rb
30
+ - lib/kiriminaja/services/address/address.rb
31
+ - lib/kiriminaja/services/courier/courier.rb
32
+ - lib/kiriminaja/services/coverage_area/coverage_area.rb
33
+ - lib/kiriminaja/services/order/order.rb
34
+ - lib/kiriminaja/services/payment/payment.rb
35
+ - lib/kiriminaja/services/pickup/pickup.rb
36
+ - lib/kiriminaja/types/address.rb
37
+ - lib/kiriminaja/types/enums.rb
38
+ - lib/kiriminaja/types/order.rb
39
+ homepage: https://developer.kiriminaja.com
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://developer.kiriminaja.com
44
+ source_code_uri: https://github.com/kiriminaja/ruby
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 3.0.0
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.2.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Official Ruby SDK for the KiriminAja logistics API
64
+ test_files: []