API kullanımına başvurmak ve test ortamının password, clientName, clientSecretKey bilgilerini almak için Farmazon'a kayıtlı e-mail adresinizden  [email protected] adresine mail atmanız yeterli. Mail içinde Farmazon kullanıcı adınızı (username) belirtmeyi ve varsa entegrasyon firmanızın adını eklemeyi unutmayın. 

Test ortamına bağlanabilmeniz için gerekli bilgileri aşağıda bulabilirsiniz. Başarılı testlerden sonra canlı ortam bilgileri sizlerle paylaşılacaktır. İşlemlere başlamak için bu dokümanı yazılımcınız ya da servis sağlayıcınız ile paylaşabilirsiniz. 

Test için BaseUrl: https://staging-api.farmazon.com.tr

Canlı için BaseUrl: lab.farmazon.com.tr  

Cevaplarda karşılaşılacak Sipariş Durum (orderStateID) bilgileri aşağıdaki gibidir.

1        - Satıcı Onayı Bekliyor
2       - Kargolanması Bekleniyor
4       - Kargoda
32     - Tamamlandı
64     - İptal Edildi
512    - Alıcı Onayı Bekleniyor
1024  - Ön Sipariş (Ödeme Alınamadı)

1.ACCESS TOKEN: 

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/account/signin
HTTP METHOD: POST

Request Headers:
Content-Type: application/x-www-form-urlencoded

Request Body Parameters: {
username : "aaaaaa" (string)
password : "bbbbbbb" (string)
clientName :"abbabbababa" (string)
    clientSecretKey : "aaaaaaa.bbbbbbbb.ccccccc.ddddddd" (string)
}

Response Body : {
    "statusCode": 200, (int)
    "statusMessage": "OK", (string)
    "result": {
        "token": "aaaaaaa.bbbbbbbb.ccccccc" (Json Web Token string),
        "tokenExpireDate": "2019-02-12T12:57:52" (string: yyyy-MM-ddTHH:mm:ss)
    },
    "errors": null
}

Bearer token'ı kullanmak için header'da göndermeniz gerekiyor. 

Örnek request;

curl -X GET "https://staging-api.farmazon.com.tr/api/v1/Orders/GetSoldOrders?page=1&count=50" -H "accept: text/plain" -H "Authorization: Bearer aaaaaaa.bbbbbbbb.ccccccc"

===========================================================================

2. GET SOLD ORDERS

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/orders/getsoldorders
HTTP METHOD: GET

Parameters:
page = 1 int  (optional)
count = 50 int  (optional)
startDate = DateTimeStringFormat(yyyy-MM-dd) (optional)
endDate = DateTimeStringFormat(yyyy-MM-dd) (optional)

Response Body:
{
    "statusCode": 200,
    "statusMessage": "OK",
    "result": [
        {
            "orderId": xxx (int),
            "orderDate": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
            "orderStateId": 32 (int),
            "orderState": "Sipariş Tamamlandı" (string),
            "orderIsUpdated": "Sipariş Güncellenmedi" (string),
            "orderNote": null (string),
            "cancelNote": null (string),
            "orderReferenceNo": "REF_AE67FC2D" (string),
            "orderPrice": 245 (decimal),
            "orderRefundPrice": 0 (decimal),
            "orderCargoPrice": 0 (decimal),
            "orderCargoRefundPrice": 0 (decimal),
            "buyerId": xxx (int),
            "buyerUsername": "aliciKullaniciAdi" (string),
            "sellerId": 150 (int),
            "sellerUsername": "saticiKullaniciAdi" (string),
            "shipmentCompany": "Yurtiçi Kargo" (string),
            "shipmentCargoCode": "XXXXXXXXXXX" (string),
            "shipmentFollowUpNo": "XXXXXXXXXXX" (string),
            "shipmentFollowUpLink": "
https://kargotakiplinki.com" (string),
            "buyerFullName": "Alici Tam Adi" (string),
            "buyerInvoiceCompanyName": "Alici Fatura Sirket Adi" (string),
            "buyerInvoicePhone": "Alici Fatura Telefon Numarasi" (string),
            "buyerInvoiceEmail": "Alici Fatura Email Adresi" (string),
            "buyerInvoiceTaxOrTcNo": "Alici Fatura Vergi No veya TC NO" (string),
            "buyerInvoiceTaxOffice": "Alici Fatura Subesi" (string),
            "buyerInvoiceAddress": "Alici Fatura Adresi" (string),
            "buyerInvoiceTown": "Alici Fatura Ilcesi" (string),
            "buyerInvoiceCity": "Alici Fatura Ili" (string),
            "buyerDeliveryAddress": "Alici Gonderim Adresi" (string),
            "buyerDeliveryTown": "Alici Gonderim Ilcesi" (string),
            "buyerDeliveryCity": "Alici Gonderim Ili" (string),
            "orderDetails": [
                {
                    "orderDetailProductName": "Batticon Antiseptik Solusyon 30 ml" (string),
                    "orderDetailProductBarcode": "8699587651242" (string),
                    "orderDetailProductVAT": 8 (int),
                    "orderDetailListingCount": 50 (int),
                    "orderDetailListingOldCount": 50 (int),
                    "orderDetailListingPrice": 4.9 (decimal),
                    "orderDetailListingExpiration": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
                    "orderDetailPrice": 245 (decimal),
                    "orderDetailRefundPrice": 0 (decimal)
                },
......
            ]
        },
........
    }
}


===========================================================================


2. GET SOLD ORDER

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/orders/getsoldorder
HTTP METHOD: GET

Parameters:
orderId = xxx (int)

Response Body:
{
    "statusCode": 200,
    "statusMessage": "OK",
    "result": [
        {
            "orderId": xxx (int),
            "orderDate": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
            "orderStateId": 32 (int),
            "orderState": "Sipariş Tamamlandı" (string),
            "orderIsUpdated": "Sipariş Güncellenmedi" (string),
            "orderNote": null (string),
            "cancelNote": null (string),
            "orderReferenceNo": "REF_XXXXXXX" (string),
            "orderPrice": 245 (decimal),
            "orderRefundPrice": 0 (decimal),
            "orderCargoPrice": 0 (decimal),
            "orderCargoRefundPrice": 0 (decimal),
            "buyerId": xxx (int),
            "buyerUsername": "aliciKullaniciAdi" (string),
            "sellerId": 150 (int),
            "sellerUsername": "saticiKullaniciAdi" (string),
            "shipmentCompany": "Yurtiçi Kargo" (string),
            "shipmentCargoCode": "XXXXXXXXXXX" (string),
            "shipmentFollowUpNo": "XXXXXXXXXXX" (string),
            "shipmentFollowUpLink": "
https://kargotakiplinki.com" (string),
            "buyerFullName": "Alici Tam Adi" (string),
            "buyerInvoiceCompanyName": "Alici Fatura Sirket Adi" (string),
            "buyerInvoicePhone": "Alici Fatura Telefon Numarasi" (string),
            "buyerInvoiceEmail": "Alici Fatura Email Adresi" (string),
            "buyerInvoiceTaxOrTcNo": "Alici Fatura Vergi No veya TC NO" (string),
            "buyerInvoiceTaxOffice": "Alici Fatura Subesi" (string),
            "buyerInvoiceAddress": "Alici Fatura Adresi" (string),
            "buyerInvoiceTown": "Alici Fatura Ilcesi" (string),
            "buyerInvoiceCity": "Alici Fatura Ili" (string),
            "buyerDeliveryAddress": "Alici Gonderim Adresi" (string),
            "buyerDeliveryTown": "Alici Gonderim Ilcesi" (string),
            "buyerDeliveryCity": "Alici Gonderim Ili" (string),
            "orderDetails": [
                {
                    "orderDetailProductName": "Batticon Antiseptik Solusyon 30 ml" (string),
                    "orderDetailProductBarcode": "8699587651242" (string),
                    "orderDetailProductVAT": 8 (int),
                    "orderDetailListingCount": 50 (int),
                    "orderDetailListingOldCount": 50 (int),
                    "orderDetailListingPrice": 4.9 (decimal),
                    "orderDetailListingExpiration": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
                    "orderDetailPrice": 245 (decimal),
                    "orderDetailRefundPrice": 0 (decimal)
                },
......
            ]
        },
........
    },
    "errors": null
}


===========================================================================


4. GET PURCHASED ORDERS

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/orders/getpurchasedorders
HTTP METHOD: GET

Parameters:
page = 1 int  (optional)
count = 50 int  (optional)
startDate = DateTimeStringFormat(yyyy-MM-dd) (optional)
endDate = DateTimeStringFormat(yyyy-MM-dd) (optional)

Response Body:
{
    "statusCode": 200,
    "statusMessage": "OK",
    "result": [
        {
            "orderId": xxx (int),
            "orderDate": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
            "orderStateId": 32 (int),
            "orderState": "Sipariş Tamamlandı" (string),
            "orderIsUpdated": "Sipariş Güncellenmedi" (string),
            "orderNote": null (string),
            "cancelNote": null (string),
            "orderReferenceNo": "REF_XXXXXXX" (string),
            "orderPrice": 245 (decimal),
            "orderPaidPrice": 245 (decimal),
            "orderRefundPrice": 0 (decimal),
            "orderCargoPrice": 0 (decimal),
            "orderCargoPaidPrice": 0 (decimal),
            "orderCargoRefundPrice": 0 (decimal),
            "installmentCount": 1 (int),
            "buyerId": xxx (int),
            "buyerUsername": "aliciKullaniciAdi" (string),
            "sellerId": xxx (int),
            "buyerLastUpdateDate": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
            "sellerLastUpdateDate": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
            "shipmentCompany": "Yurtiçi Kargo" (string),
            "shipmentCargoCode": "XXXXXXXXXXX" (string),
            "shipmentFollowUpNo": "XXXXXXXXXXX" (string),
            "shipmentFollowUpLink": "
https://kargotakiplinki.com" (string),
            "orderDetails": [
                {
                    "orderDetailProductName": "Batticon Antiseptik Solusyon 30 ml" (string),
                    "orderDetailProductBarcode": "8699587651242" (string),
                    "orderDetailProductVAT": 8 (int),
                    "orderDetailListingCount": 50 (int),
                    "orderDetailListingOldCount": 50 (int),
                    "orderDetailListingPrice": 4.9 (decimal),
                    "orderDetailListingExpiration": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
                    "orderDetailPrice": 245 (decimal),
                    "orderDetailRefundPrice": 0 (decimal)
                },
......
            ]
        },
........
    },
    "errors": null
}


===========================================================================


5. GET PURCHASED ORDER

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/orders/getpurchasedorder
HTTP METHOD: GET

Parameters:
orderId = xxx (int)

Response Body:
{
    "statusCode": 200,
    "statusMessage": "OK",
    "result": [
        {
            "orderId": xxx (int),
            "orderDate": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
            "orderStateId": 32 (int),
            "orderState": "Sipariş Tamamlandı" (string),
            "orderIsUpdated": "Sipariş Güncellenmedi" (string),
            "orderNote": null (string),
            "cancelNote": null (string),
            "orderReferenceNo": "REF_XXXXXXX" (string),
            "orderPrice": 245 (decimal),
            "orderPaidPrice": 245 (decimal),
            "orderRefundPrice": 0 (decimal),
            "orderCargoPrice": 0 (decimal),
            "orderCargoPaidPrice": 0 (decimal),
            "orderCargoRefundPrice": 0 (decimal),
            "installmentCount": 1 (int),
            "buyerId": xxx (int),
            "buyerUsername": "aliciKullaniciAdi" (string),
            "sellerId": xxx (int),
            "shipmentCompany": "Yurtiçi Kargo" (string),
            "shipmentCargoCode": "XXXXXXXXXXX" (string),
            "shipmentFollowUpNo": "XXXXXXXXXXX" (string),
            "shipmentFollowUpLink": "
https://kargotakiplinki.com" (string),
            "orderDetails": [
                {
                    "orderDetailProductName": "Batticon Antiseptik Solusyon 30 ml" (string),
                    "orderDetailProductBarcode": "8699587651242" (string),
                    "orderDetailProductVAT": 8 (int),
                    "orderDetailListingCount": 50 (int),
                    "orderDetailListingOldCount": 50 (int),
                    "orderDetailListingPrice": 4.9 (decimal),
                    "orderDetailListingExpiration": "2017-08-03T13:16:28" (string: yyyy-MM-ddTHH:mm:ss),
                    "orderDetailPrice": 245 (decimal),
                    "orderDetailRefundPrice": 0 (decimal)
                },
......
            ]
        }
    },
    "errors": null
}

===========================================================================

6. CREATE LISTINGS

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/listings/createlistings
HTTP METHOD: POST

Request Headers:
Content-Type: application/json

Parameters:
[
  {
    "price": 0, (Required)
    "stock": 0, (Required)
    "expiration": "2019-06-21T13:37:40.291Z",
    "maxCount": 0,
    "description": "string",
    "isFeatured": true,
    "product": {
      "id": 0,
      "name": "string", (Required)
      "barcode": "string", (Required)
      "psf": 0,
      "vat": 0,
      "image": "string"
    }
  }
]


Response Body:{

{
    "statusCode": 200,
    "statusMessage": "OK",
    "result": {
        "listings": [
            {
                "id": XXXXX (int => listing id),
                "state": false (bool),
                "product": {
                    "name": "Supradyn Koenzim Q10 30 Tablet", (string)
                    "barcode": "xxxxxxxxx" (string)
                }
            },
            {
                "id": XXXXX (int => listing id),
                "state": false (bool),
                "product": {
                    "name": "Supradyn Koenzim Q10 30 Tablet", (string)
                    "barcode": "xxxxxxxxx" (string)
                }
            },
           
            ............

        ]
    },
    "errors": null
}
}

===========================================================================

7. UPDATE LISTINGS

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/listings/updatelistings
HTTP METHOD: PUT

Request Headers:
Content-Type: application/json

Parameters:
[
    {
        "id": xxxx, (int => listing id)
        "price": 500,
        "stock": 305,
        "state":1, (active:1 , passive:2)
        "expiration": "2019-02-12T12:57:52", (string: yyyy-MM-ddTHH:mm:ss, optional),
        "maxCount": 254,
        "description": "xxxxxxxx xxxxx xxx",
        "isFeatured":true, (bool)
        "product":{        (optional)
            "psf":10.5 (decimal, optional),
            "barcode":"123456324278" (optional)
       }
    },
    {
        "id": xxxx, (int => listing id)
        "price": 500,
        "stock": 305,
        "state":1, (active:1 , passive:2)
        "expiration": "2019-02-12T12:57:52", (string: yyyy-MM-ddTHH:mm:ss, optional),
        "maxCount": 254,
        "description": "xxxxxxxx xxxxx xxx",
        "isFeatured":true, (bool)
        "product":{        (optional)
            "psf":10.5 (decimal, optional),
            "barcode":"123456324278" (optional)
       }
    },
    {
        "id": xxxx, (int => listing id)
        "price": 500,
        "stock": 305,
        "state":1, (active:1 , passive:2)
        "expiration": "2019-02-12T12:57:52", (string: yyyy-MM-ddTHH:mm:ss, optional),
        "maxCount": 254,
        "description": "xxxxxxxx xxxxx xxx",
        "isFeatured":true, (bool)
        "product":{        (optional)
            "psf":10.5 (decimal, optional),
            "barcode":"123456324278" (optional)
       }
    },
   
    ............

]

Response Body:{

    {
        "statusCode": 200,
        "statusMessage": "OK",
        "result": [
            {
                "id": xxxx, (int => listing id)
                "price": 500,
                "stock": 305,
                "expiration": "2019-02-12T12:57:52", (string: yyyy-MM-ddTHH:mm:ss, optional),
                "maxCount": 254,
                "description": "xxxxxxxx xxxxx xxx"
            },
            {
                "id": xxxxx, (int => listing id)
                "price": 500,
                "stock": 305,
                "expiration": "2019-02-12T12:57:52", (string: yyyy-MM-ddTHH:mm:ss, optional),
                "maxCount": 254,
                "description": "xxxxxxxx xxxxx xxx"
            },
            {
                "id": xxxx, (int => listing id)
                "price": 500,
                "stock": 305,
                "expiration": "2019-02-12T12:57:52", (string: yyyy-MM-ddTHH:mm:ss, optional),
                "maxCount": 254,
                "description": "xxxxxxxx xxxxx xxx"
            },
           
            ............
        ],
        "errors": null
    }
}

===========================================================================

8. SET SHIPMENT INFOS

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/orders/setshipmentinfos
HTTP METHOD: PUT

Request Headers:
Content-Type: application/json

Parameters:
orderId = xx (int)
shipmentCompany == "Yurtiçi Kargo" (string)
followUpNo = "xxxxxxxx" (string)
followUpLink = "
https://www.cargolink.com/abc"

Response Body: {
    {
        "statusCode": 200,
        "statusMessage": "OK",
        "result": true,
        "errors": null
    }
}

============================================================================================

9. GET LISTINGS

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/listings/getlistings
HTTP METHOD: GET

Parameters:
page integer($int32)(query) Default value : 1
count integer($int32) (query) Default value : 50
listingState integer($int32) (query) Default value : 1 (active: 1, passive: 2)

Response Body: {
    "statusCode": 200,
    "statusMessage": "OK",
    "result": [
        {
            "id": xxx,
            "price": 20.5,
            "stock": 300,
            "maxCount": 108,
            "description": null, (string, optional)
            "expiration": "2020-05-01T00:00:00",
            "isFeatured": true,
            "product": {
                "id": 123456,
                "name": "xxxxxxx",
                "barcodes": [
                    {
                        "barcode": "123456789",
                        "isSelected": false
                    },
                    {
                        "barcode": "123456789",
                        "isSelected": true
                    }
                ]
            }
        },
        {
            "id": xxx,
            "price": 20.5,
            "stock": 300,
            "maxCount": 108,
            "description": null, (string, optional)
            "expiration": "2020-05-01T00:00:00",
            "isFeatured": true,
            "product": {
                "id": 123456,
                "name": "xxxxxxx xxxxxx xxxx",
                "barcodes": [
                    {
                        "barcode": "12346789",
                        "isSelected": false
                    },
                    {
                        "barcode": "123456789",
                        "isSelected": true
                    }
                ]
            }
        },

        ............

    ],
    "errors": null
}

===========================================================================

10. GET LISTING

Request Format:
Url:
https://staging-api.farmazon.com.tr/api/v1/listings/getlisting
HTTP METHOD: GET

Parameters:
listingId integer($int32) (Required)

Response Body: {                      
    "statusCode": 200,                  
    "statusMessage": "OK",                      
    "result":
          {            
               "id": xxx,            
               "price": 20.5,            
               "stock": 300,            
               "maxCount": 108,            
               "description": "description",          
               "expiration": "2020-05-01T00:00:00",            
               "isFeatured": true,        
               "listingState
": 1, (active: 1, passive: 2)
                "product":
                         {
                             "id": 123456,
                             "name": "xxxxxxx",
                             "barcodes": [                    
                                     {                        
                                          "barcode": "123456789",
                                          "isSelected": false                    
                                    },
                                    {
                                          "barcode": "123456789",
                                          "isSelected": true                   

                                   }                
                             ]            
                         }
        }

Aradığınız yanıtı buldunuz mu?