ozan12 Önce Guzzle kütüphanesi kurulu değilse onu kuracaksınız:
composer require guzzlehttp/guzzle
Sonra token almanız gerekiyor:
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.parasut.com'
]);
$response = $client->post('oauth/token', [
'form_params' => [
'grant_type' => 'password',
'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob'
// Bu bilgileri doldurun:
'client_id' => 'client id buraya',
'client_secret' => 'client secret buraya',
'username' => 'kullanici adi buraya',
'password' => 'sifre buraya',
]
]);
$content = json_decode($response->getBody());
$token = $content->access_token;
/*
$refreshToken = $content->refresh_token;
$createdAt = $content->created_at;
$expiresIn = $content->expires_in;
$scope = $content->scope;
*/
Artık token ile istek atabilirsiniz, örneğin satış faturası oluşturma:
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.parasut.com/v4'
]);
$data = [
'data' => [
'id' => 'string',
'type' => 'sales_invoices',
'attributes' => [
'item_type' => 'invoice',
'description' => 'string',
'issue_date' => '2021-12-08',
'due_date' => '2021-12-08',
'invoice_series' => 'string',
'invoice_id' => 0,
'currency' => 'TRL',
'exchange_rate' => 0,
'withholding_rate' => 0,
'vat_withholding_rate' => 0,
'invoice_discount_type' => 'percentage',
'invoice_discount' => 0,
'billing_address' => 'string',
'billing_phone' => 'string',
'billing_fax' => 'string',
'tax_office' => 'string',
'tax_number' => 'string',
'country' => 'string',
'city' => 'string',
'district' => 'string',
'is_abroad' => true,
'order_no' => 'string',
'order_date' => '2021-12-08',
'shipment_addres' => 'string',
'shipment_included' => true,
'cash_sale' => true,
'payment_account_id' => 0,
'payment_date' => 'string',
'payment_description' => 'string',
],
'relationships' => [
'details' => [
'data' => [
[
'id' => 'string',
'type' => 'sales_invoice_details',
'attributes' => [
'quantity' => 0,
'unit_price' => 0,
'vat_rate' => 0,
'discount_type' => 'percentage',
'discount_value' => 0,
'excise_duty_type' => 'percentage',
'excise_duty_value' => 0,
'communications_tax_rate' => 0,
'description' => 'string',
'delivery_method' => 'CFR',
'shipping_method' => 'Belirtilmedi',
],
'relationships' => [
'product' => [
'data' => [
'id' => 'string',
'type' => 'products',
],
],
'warehouse' => [
'data' => [
'id' => 'string',
'type' => 'warehouses',
],
],
],
],
],
],
'contact' => [
'data' => [
'id' => 'string',
'type' => 'contacts',
],
],
'category' => [
'data' => [
'id' => 'string',
'type' => 'item_categories',
],
],
'tags' => [
'data' => [
[
'id' => 'string',
'type' => 'tags',
],
],
],
'sales_offer' => [
'data' => [
'id' => 'string',
'type' => 'sales_offers',
],
],
],
],
]
// 12345 burada firma id'niz
$response = $client->post('12345/sales_invoices', [
'json' => $data,
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/json',
'Content-type' => 'application/json',
]
]);