# 控除履歴 取得

`GET /v1/platform_fee_deductions/{id}`

- operationId: `retrievePlatformFeeDeduction`
- tags: プラットフォーム控除

`id`で指定した控除履歴を取得します。\
\
プラットフォーム（メインショップ）のAPIキーでのみ実行できます。テナントショップのAPIキーでは実行できません。


## コードサンプル

### cURL

```bash
curl \
    -X GET \
    -H "Authorization:Bearer <Secret API Key>" \
'https://api.test.fincode.jp/v1/platform_fee_deductions/{id}'
```

### Node.js

```javascript
const API_KEY = "<Secret API Key>";

(async () => {
    const platformFeeDeductionId = "<Platform Fee Deduction ID>";

    const response = await fetch(`https://api.test.fincode.jp/v1/platform_fee_deductions/${platformFeeDeductionId}`, {
        method: "GET",
        headers: {
            Authorization: `Bearer ${API_KEY}`,
        },
    });

    const data = await response.json();
    console.log(data);
})();
```

### Go

```go
package main

import (
	"fmt"
	"log"
	"net/http"
)

func main() {

	apiKey := "<Secret API Key>"

	platformFeeDeductionID := "<Platform Fee Deduction ID>"

	// リクエストの作成
	req, _ := http.NewRequest(
		"GET",
		fmt.Sprintf("https://api.test.fincode.jp/v1/platform_fee_deductions/%s", platformFeeDeductionID),
		nil,
	)
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))

	// リクエストの送信
	client := &http.Client{}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

}
```

### PHP

```php
<?php

$apiKey = '<Secret API Key>';

$platformFeeDeductionId = '<Platform Fee Deduction ID>';

$baseUrl = "https://api.test.fincode.jp";
$endpoint = "/v1/platform_fee_deductions/{$platformFeeDeductionId}";

$headers = [
    "Authorization: Bearer " . $apiKey,
];

$session = curl_init();
curl_setopt($session, CURLOPT_URL, $baseUrl . $endpoint);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_HTTPGET, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($session, CURLOPT_SSL_VERIFYPEER, );
// curl_setopt($session, CURLOPT_SSL_VERIFYHOST, );

$response = curl_exec($session);

if ($response === false) {
    # エラー処理
    echo "cURL Error: " . curl_error($session);
} else {
    # APIからのデータを処理
    var_dump($response);
}

curl_close($session);
```

### Python 3

```python
import requests

api_key = '<Secret API Key>'

platform_fee_deduction_id = '<Platform Fee Deduction ID>'

url = f'https://api.test.fincode.jp/v1/platform_fee_deductions/{platform_fee_deduction_id}'

# ヘッダーを設定
headers = {
    'Authorization': f'Bearer {api_key}',
}

try:
    response = requests.get(url, headers=headers)

    # レスポンスの処理
    if response.status_code == 200:
        # APIからのデータを処理
        print(f"Success: {response.json()}")
    else:
        # エラーの処理
        print(f"Error: {response.json()}")
except requests.RequestException as e:
    # 通信エラーの処理
    print(f"Request error: {e}")
```

### Ruby

```ruby
require 'net/http'
require 'uri'
require 'json'

API_KEY = '<Secret API Key>'
BASE_URL = 'https://api.test.fincode.jp'

def main
    platform_fee_deduction_id = '<Platform Fee Deduction ID>'
    endpoint = "/v1/platform_fee_deductions/#{platform_fee_deduction_id}"

    uri = URI.parse(BASE_URL + endpoint)

    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true

    # リクエストの作成
    request = Net::HTTP::Get.new(uri.request_uri)
    request['Authorization'] = "Bearer #{API_KEY}"

    # リクエストの送信
    response = http.request(request)

    case response
    when Net::HTTPSuccess
        puts 'SUCCESS'
    else
        puts 'ERROR'
    end

    # レスポンスの表示
    puts response.body
end

main
```

## パラメータ

| 名前 | 位置 | 必須 | 型 | 説明 |
| --- | --- | --- | --- | --- |
| `id` | path | ✓ | PlatformFeeDeductionId_schema | 控除履歴ID |

## レスポンス

### 200 リクエストに成功

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `id` | string |  | 控除履歴ID |
| `shop_id` | string |  | プラットフォーム（メインショップ）のショップID |
| `tenant_shop_id` | string |  | 控除の対象となったテナントショップのショップID |
| `tenant_shop_name` | string |  | 控除の対象となったテナントショップのショップ名 |
| `fee_type` | PlatformFeeDeductionFeeType |  |  |
| `status` | PlatformFeeDeductionStatus |  |  |
| `amount` | integer(int64) |  | 控除金額（税抜） |
| `tax` | integer(int64) |  | 消費税額 |
| `total_amount` | integer(int64) |  | 控除金額の合計（`amount` + `tax`） |
| `deposit_id` | string |  | 控除元となったテナントショップの売上入金ID。 |
| `platform_deposit_id` | string |  | 計上先となったプラットフォーム利用料収入ID。 |
| `deposit_cycle_master_id` | integer |  | 控除元となった売上入金の入金サイクルのID。 |
| `aggregate_term_start` | string |  | 控除の対象となる集計期間の開始日 |
| `aggregate_term_end` | string |  | 控除の対象となる集計期間の終了日 |
| `created` | created |  |  |
| `updated` | updated |  |  |

### 400 不正なリクエスト

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `errors` | array<FincodeAPIError> |  |  |

