# Kolay Gelsin Shipment Extension

## <mark style="color:red;">**Extension Installation**</mark>

### <mark style="color:red;">**Preliminary Works**</mark>

The following information is requested from the provider for the brand-specific and production (live) environment.

* **API\_URL**
* **API\_USERNAME**
* **API\_TOKEN**
* **CUSTOMER\_ID**
* **ADDRESS\_ID**

A `secret_key` is generated with a minimum length of 41 characters. The generated key must be kept throughout the installation. An example command line to generate a random key:

```bash
openssl rand -base64 41
```

An address ID must be set for the default destination information in easy-return shipments. It can be created using the extension's address creation method (example curl is given below). Ensure that the address ID is accurately configured to facilitate the smooth handling of return shipments within the Omnitron configuration.

```bash
curl --location 'https://<extension_url>/addresses' \
--header 'x-akinon-request-id: <guid>' \
--header 'x-akinon-api-version: 1.0' \
--header 'Authorization: Basic <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id": <id(str)>, // return_destination_extension_id in Omnitron config,
    "addressName": "Jacobs Group",
    "addressDescription": "totam quisquam qui",
    "phone": "+90 216 555 1234",
    "email": "Marlee42@example.net",
    "type": "PICK_UP_LOCATION",
    "address": {
        "country": {
            "id": 0, // optional
            "code": "TR",
            "name": "Türkiye"
        },
        "city": {
            "id": 0, // optional
            "name": "Istanbul"
        },
  "township": {
            "id": 0, // optional
            "name": "Kadıköy"
        },
        "district": {
            "id": 0, // optional
            "name": "Acıbadem"
        },
        "zipcode": "34100",
        "addressLine": "Caferağa Mahallesi, Dr. Esat Işık Caddesi No:35"
    }
}'
```

In order to send the correct data to Kolay Gelsin, the product attribute with the code names\
“deci” must be defined.

### <mark style="color:red;">**Environment Variables**</mark>

The extension installed to the relevant project in ACC must have the following environment variables. Environment variables can be entered before or after the deployment phase. As changes are made to the environment variables, the deployment process must be performed again.

<table><thead><tr><th width="244.24609375">Variable</th><th>Description</th></tr></thead><tbody><tr><td><em><strong>Extension-specific</strong></em></td><td></td></tr><tr><td>API_URL</td><td>URL received during the preliminary works phase (without a trailing slash at the end)</td></tr><tr><td>API_USERNAME</td><td>API USERNAME received during the preliminary works phase</td></tr><tr><td>API_TOKEN</td><td>API TOKEN received during the preliminary works phase. It should be retrieved from Kolay Gelsin, on a yearly basis.</td></tr><tr><td>CUSTOMER_ID</td><td>CUSTOMER ID received during the preliminary works phase.</td></tr><tr><td>ADDRESS_ID</td><td>Sender ADDRESS ID received during the preliminary works phase. The address should be added via Kolay Gelsin Dashboard. After adding the address, the ID should be mapped to the same address in OMS/Omnitron using ADDRESS_ID mapping as explained in the Mapping section of this document.</td></tr><tr><td><em><strong>Generic</strong></em></td><td></td></tr><tr><td>SECRET_KEY</td><td>The generated secret key during the preliminary works phase</td></tr><tr><td>ADMIN_EMAIL</td><td>The e-mail address of the installer can be entered</td></tr><tr><td>ADMIN_PASSWORD</td><td>A newly created and extension-specific strong password</td></tr><tr><td>ADMIN_USERNAME</td><td>A username can be entered (example: ‘akinon’)</td></tr></tbody></table>

## <mark style="color:red;">**Omnitron Settings**</mark>

Kolay Gelsin can be selected as the Shipment Provider in Omnitron to integrate with the extension installed. Additionally, an easy return option can be defined to enable easy return methods. Explanations on how these settings can be configured are detailed in the sections below. Please note that these two operations are independent and optional.

### <mark style="color:red;">**Shipping Provider**</mark>

To add Kolay Gelsin, a new shipping provider is added to SHIPPING\_PROVIDERS in Dynamic Settings through Omnitron.

**Example Omnitron Configuration:**

<table><thead><tr><th width="169.38671875">Field</th><th>Description</th></tr></thead><tbody><tr><td>Klass</td><td>ExtensionShippingProvider Class</td></tr><tr><td>Urls Code</td><td><p>{</p><p>"urls": {</p><p>"base_url": "{<code>SHIPMENT_EXTENSION_URL</code>}"</p><p>}</p><p>}</p></td></tr><tr><td>Serializers</td><td>Order Serializer: ExtensionShippingOrderSerializer Class Response Serializer: ExtensionShippingResponseSerializer Class</td></tr><tr><td>Configurations Code</td><td><p>{</p><p>"strategies": {</p><p>"query_type": "SHIPMENT_ID",</p><p>"generate_shipment_origin_strategy": "&#x3C;addressId>",</p><p>"generate_shipment_product_strategy": true,</p><p>"generate_shipment_product_attributes": [</p><p>"deci"</p><p>]</p><p>},</p><p>"pay_on_delivery_option": false,</p><p>"delivery_type": "CUSTOMER",</p><p>"auth": {</p><p>"username": "{<code>SHIPMENT_EXTENSION_ADMIN_USERNAME</code>}",</p><p>"password": "{<code>SHIPMENT_EXTENSION_ADMIN_PASSWORD</code>}"</p><p>},</p><p>"is_active": {</p><p>"query": true,</p><p>"send_shipping_info": true,</p><p>"delete_shipping_info": true,</p><p>"query_by_order": true</p><p>},</p><p>"label_options": {</p><p>"file_extension": "html"</p><p>}</p><p>}</p></td></tr></tbody></table>

### <mark style="color:red;">**Easy Return Shipping Option**</mark>

One easy return shipping option must be defined in Omnitron to be specific for the extension installed. Explanations on how the settings should be made at this stage are in the section below.

**Example Omnitron Configuration:**

<table><thead><tr><th width="262.0859375">Field</th><th>Description</th></tr></thead><tbody><tr><td>Shipping Company</td><td>Extension Cargo</td></tr><tr><td>Shipping Company Auth Code</td><td><p>{</p><p>"url": "{SHIPMENT_EXTENSION_URL}",</p><p>"username": "{<code>SHIPMENT_EXTENSION_ADMIN_USERNAME</code>}",</p><p>"password": "{<code>SHIPMENT_EXTENSION_ADMIN_PASSWORD</code>}",</p><p>“send_user_address”: True,</p><p>“easy_return_product_strategy”: True,</p><p>"return_destination_extension_id":"{address_id}"</p><p>“product_attributes”: {</p><p>"barcode": "{product_barcode_attribute}",</p><p>"description": "{product_description_attribute}",</p><p>"name": "{product_name_attribute}"<br>}</p><p>}</p></td></tr><tr><td>Start Date Gap</td><td>This variable is used to delay the start date for using the return code. If this value is set to 0, the customer can request a refund on the same day.</td></tr><tr><td>Delivery Time</td><td>The delivery_time variable indicates the duration for which the return code will be valid and usable. If the product is not shipped by the customer within this period, the code becomes invalid.</td></tr><tr><td>Shipping Company Prefix</td><td>If a prefix is to be added to the return code, this field should contain the short name of the brand. This short name can be any value determined by the brand.</td></tr><tr><td>Shipping Company Rules</td><td><p>{</p><p>"product": {</p><p>"field_key": "attributes__easy_return_method",</p><p>"field_values": [</p><p>[</p><p>"",</p><p>null</p><p>]</p><p>]</p><p>}</p><p>}</p></td></tr><tr><td>Status</td><td>active</td></tr></tbody></table>

## <mark style="color:red;">**Mapping**</mark>

Mapping is mandatory to use Kolay Gelsin Shipment Extension properly. There are 2 types of mapper. City mapper is defined for you. You need to define `ADDRESS_ID` mapper:

<table><thead><tr><th width="180.265625">Mapper Type</th><th>Description</th></tr></thead><tbody><tr><td>CITY</td><td>CITY value provided by the Kolay Gelsin Delivery Module. Must be formatted as “<strong><code>{city_id}</code></strong>”. Example: “34” for İstanbul. Plate numbers should be used as value (city_id). These are already added into fixtures, if more needed, it can be added via mapper defined below.</td></tr><tr><td>ADDRESS_ID</td><td>WAREHOUSE ID value provided by the Kolay Gelsin Delivery Module. It is used for mapping the extension's address_id information, which corresponds to the addresses designated as the departure point for shipments and/or the destination for returns, to the Kolay Gelsin Warehouse ID.</td></tr></tbody></table>

{% hint style="warning" %}

* In the Kolay Gelsin Delivery Module, the address flow is defined in the sequence of Country, City, Township, and District.
* Below are examples of the requests that need to be sent to the Kolay Gelsin Delivery Module to obtain the information specified here.
  {% endhint %}

#### **Steps to Use the Mapper Method for the ADDRESS TITLE:**

1. **Create an Address:** Create an address according to your warehouse information and obtain its title.
2. **Map Address ID with `warehouse_id`:** The mapping method takes three values: type, key, and value.
   * **Type:** Currently, the type is fixed as `ADDRESS_ID`.
   * **Key:** Use the created address title as the key.
   * **Value:** Assign the `warehouse_id` taken from Kolay Gelsin as the value. Example: `1`.

When a request comes in with a specific address title, the outgoing request should include the corresponding warehouse\_id if a mapping exists.

<table><thead><tr><th width="267.19921875">Field</th><th>Description</th></tr></thead><tbody><tr><td>Extension URL</td><td>The URL of the shipment extension</td></tr><tr><td>Username</td><td>Extension user's name for authorization</td></tr><tr><td>Password</td><td>Extension user's password for authorization</td></tr><tr><td>Type</td><td>ADDRESS_ID</td></tr><tr><td>Key</td><td>Desired Address Title for Address Information</td></tr><tr><td>Value</td><td>Address ID value at the KOLAY GELSIN</td></tr></tbody></table>

**Generate Mapping Request:**

```bash
curl -X POST {{extension_url}}/mapper \
     -u username:password \
     -H "Content-Type: application/json" \
     -d '{
           "type": "",
           "key": "",
           "value": ""
         }'
```

**Update Mapping Request:**

The values for `key`, `type`, and `value` should be updated.

```bash
curl -X PATCH "{{extension_url}}/mapper/<id>" \
     -u username:password \
     -H "Content-Type: application/json" \
     -d '{
           "type": "",
           "key": "",
           "value": ""
         }'
```

**Get Mapping Request:**

When making a query request, it can be filtered by the fields `type`, `key`, `value`, `created_date` and `modified_date`.

```bash
curl -X GET "{{extension_url}}/mapper?key=<key>" \
     -u username:password \
     -H "Content-Type: application/json"
```

**Delete Mapping Request:**

```bash
curl -X DELETE "{{extension_url}}/mapper/<id>" \
     -u username:password \
     -H "Content-Type: application/json"
```

## **Notes**

1. `API_TOKEN` must be obtained from Kolay Gelsin or its dashboard on a yearly basis.
2. `fixtures.json` file should be loaded for city mapping. If additional mappings are required, a CITY mapping should be added through the mapper.
3. On the Dashboard, go to **Webhook → Webhook Settings** and perform the following action:
   1. Disable the webhook (set “Web servisime geri bildirim istiyorum” to **False**).
   2. Most cargo statuses (**Kargo Aksiyonları**) should be checked for both FORWARD and REVERSE shipments. However, the statuses listed below should not be checked for either. If they are currently checked, please uncheck them.
      1. Gönderen bilgisi değişti
      2. Zimmet Bırakıldı
      3. Görev tamamlandı
      4. Hatalı Sevk Okutması Yapıldı
      5. Müşteri Kaynaklı Hatalı Sevk
      6. Kolay Gelsin Kaynaklı Hatalı Sevk
      7. Hatalı Sevk Değil


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akinon.com/technical-guides/3rd-party-integration/shipment-integrations/kolay-gelsin-shipment-extension.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
