---
# System prepended metadata

title: Indah Logistik API Integration

---

# Indah Logistik COD Integration (December 2023)
## Existing Flow
### Generate AWB Internal
```plantuml
participant "everpro-logistic-client" as elc
participant "everpro-3pl-aggregator" as 3plAgg
database "popaket_logistic" as db1
participant "3pl" as 3pl


activate elc
elc -> elc
note left
...
existing generate awb logic
...
end note
elc -> elc: prepare generate awb data
elc -> 3plAgg: send grpc generate awb
note left
using flow `new generate awb`
end note
activate 3plAgg
3plAgg -> db1: get mapping location data
note right
table `logistic_codes`
get data: 
- origin_code 
- destination_code
- is_enable_cod
etc..
end note
db1 --> 3plAgg: return data
3plAgg -> 3plAgg: process generate awb data
3plAgg -> 3pl: generate awb to 3pl
3pl --> 3plAgg: return awb data
3plAgg -> 3pl: request pickup to 3pl
3pl --> 3plAgg: return response
3plAgg --> elc: return awb data response
deactivate 3plAgg
elc -> db1: update status and awb
elc -> elc
note left
...
existing generate awb logic
...
end note
```

### Generate AWB External
```plantuml
participant "everpro-order" as eo
participant "NSQ" as nsq
participant "everpro-3pl-aggregator" as 3plAgg
database "popaket_logistic" as db1
participant "3pl" as 3pl
database "popaket_order" as db2

activate eo
eo -> eo
note left
...
existing generate awb logic
...
end note
eo -> eo : prepare generate awb data
eo -> nsq : produce generate awb
deactivate eo
nsq -> 3plAgg: consume genarate awb
activate 3plAgg
3plAgg -> db1: get mapping location data
note right
table `logistic_codes`
get data: 
- origin_code 
- destination_code
- is_enable_cod
etc..
end note
db1 --> 3plAgg: return data
3plAgg -> 3plAgg: process generate awb data
3plAgg -> 3pl: generate awb to 3pl
3pl --> 3plAgg: return awb data
3plAgg -> 3pl: request pickup to 3pl
3pl --> 3plAgg: return response
3plAgg -> nsq : produce update awb number
deactivate 3plAgg
nsq -> eo : consume update awb number
activate eo
eo -> db2 : update status and awb
```

## Solution Flow
### Generate AWB
```plantuml
participant "everpro-logistic-client/everpro-order" as os
participant "everpro-3pl-aggregator" as 3plAgg
database "popaket_logistic" as db1
participant "3pl" as 3pl

activate os
os -> os
note left
...
existing generate awb flow
...
end note
os -> 3plAgg: send generate awb request
activate 3plAgg
3plAgg -> db1: get mapping location data
note left
table `logistic_codes`
get data: 
- origin_code 
- destination_code
- is_enabled_cod
etc..
end note
db1 --> 3plAgg: return data
3plAgg -> 3plAgg: process generate awb data
note right
if the order type is cod: 
will send the`nominal_barang` value to 3pl
end note
3plAgg -> 3pl: generate awb to 3pl
note right
if the order type is cod: 
will request generate awb to endpoint `insert_trans_cod`
end note
3pl --> 3plAgg: return awb data
3plAgg -> 3pl: request pickup to 3pl
3pl --> 3plAgg: return response
3plAgg --> os: return response
deactivate 3plAgg
os -> os
note left
...
existing generate awb flow
...
end note
```

# Indah Logistik API Integration in Core Logistic (November 2024)
## Get Rates
```plantuml
actor client
participant "evm-3pl-client-gateway" as gateway
participant "evm-3pl-logistic" as logistic
participant "evm-3pl-aggregator" as aggregator
participant "evm-3pl-location" as location
participant 3pl

client -> gateway : <<send request get rates>>
activate gateway
gateway -> logistic : <<send rpc request get rates>>
activate logistic
logistic ->logistic : validate logistic settings
logistic -> aggregator : <<send rpc request get rates to 3pl>>
activate aggregator


aggregator -> location: get location code
location --> aggregator : return location data

alt if request is use COD
aggregator -> aggregator : set request get rates param id_layanan = 8:Expres
note left
because only service `8:Expres` is eligible to use COD
end note
end

aggregator -> 3pl : <<send request get rates>>
3pl --> aggregator : return response

aggregator --> logistic: return rates response
deactivate aggregator
logistic --> gateway: return rates response
deactivate logistic
gateway --> client: return rates response
deactivate gateway

```

## Create Order
```plantuml
actor client
participant "evm-3pl-client-gateway" as gateway
participant "evm-3pl-logistic" as logistic
database "evm_3pl_logistic" as db1
participant "evm-3pl-aggregator" as aggregator
participant "evm-3pl-location" as location
participant 3pl
participant "evm-notif-publisher" as notif

client -> gateway : <<send request create order>>
activate gateway
gateway -> logistic: <<send rpc request create order>>
activate logistic
logistic -> db1 : insert new order data
db1 --> logistic : return
logistic -> aggregator : <<send rpc request create order/generate awb to 3pl>>
activate aggregator

aggregator -> location: get location code
location --> aggregator : return location data

aggregator -> 3pl : <<send request create order>>
3pl --> aggregator : return response

alt if shipment type is pickup
aggregator -[#blue]> 3pl : <<send request pickup>>
3pl -[#blue]-> aggregator : return response
alt if error
aggregator -> notif : send notif failed request pickup
end
end


aggregator --> logistic: return awb response
deactivate aggregator
logistic -> db1: update awb number
db1 --> logistic: return

logistic --> gateway: return awb response
deactivate logistic
gateway --> client: return awb response
deactivate gateway
```

## Request Pickup
```plantuml
actor user
participant "evm-3pl-aggregator" as aggregator
participant "evm-3pl-logistic" as logistic
participant 3pl

user -> aggregator : <<send request pickup to 3pl>>
activate aggregator
aggregator -> logistic : <<send request get order detail>>
logistic --> aggregator : return data
aggregator -> aggregator: validate order status
note left
order status should still be waiting for pickup/dropoff
end note
deactivate aggregator

```

## Webhook Tracking
```plantuml
actor client
participant "evm-3pl-logsitic" as logistic
participant "evm-3pl-log" as log
participant "evm-3pl-aggregator" as aggregator
participant 3pl

3pl -> aggregator: send webhook tracking
activate aggregator
aggregator -> aggregator: formating webhook payload
aggregator -> log : store log webhook (use queue)
aggregator -> logistic : update order status and send callback tracking to client
deactivate aggregator
logistic -> client: send callback tracking

```