# 売上入金 取得

`GET /v1/accounts/{id}`

- operationId: `retrieveAccount`
- tags: 売上入金

IDで指定した売上入金を取得します。\
`aggregate_term_start`から`aggregate_term_end`までの期間における売上の集計結果が含まれます。\
\
集計された個々のレコードについては 売上入金明細 一覧取得API を利用することで取得できます。


## コードサンプル

### cURL

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

### Node.js

```javascript
import { createFincode } from "@fincode/node";

const API_KEY = "<Secret API Key>";

(async () => {
    const fincode = createFincode({ apiKey: API_KEY, isLiveMode: false });

    const accountId = "<Account ID>";

    try {
        // リクエストの送信
        const account = await fincode.accounts.retrieve(accountId);
    } catch (e) {
        // エラーの処理
    }
})();
```

### Go

```go
package main

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

func main() {

	apiKey := "<Secret API Key>"

	accountID := "<Account ID>"

	// リクエストの作成
	req, _ := http.NewRequest("GET", fmt.Sprintf("https://api.test.fincode.jp/v1/accounts/%s", accountID), 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>';

$accountId = '<Account ID>';

$baseUrl = "https://api.test.fincode.jp";
$endpoint = "/v1/accounts/{$accountId}";
$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>'

account_id = '<Account ID>'

url = f'https://api.test.fincode.jp/v1/accounts/{account_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'

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

def main
    account_id = '<Account ID>'
    endpoint = "/v1/accounts/#{account_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 | ✓ | AccountId_schema | 売上入金ID |
| `Tenant-Shop-Id` | header |  | schema | <span class="smallText color--red-400">※ プラットフォームのメインショップのみ指定可</span> |

## レスポンス

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

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `id` | string |  | 売上入金ID |
| `account_id` | integer |  | 精算ID |
| `shop_id` | string |  | ショップID |
| `deposit_amount` | integer(int64) |  | 売上入金 入金額 |
| `deposit_date` | string |  | 売上入金 入金実績日 |
| `scheduled_deposit_date` | string |  | 売上入金 入金予定日 |
| `aggregate_term_start` | string |  | 売上入金 集計期間の開始日 |
| `aggregate_term_end` | string |  | 売上入金 集計期間の終了日 |
| `payment_deadline` | string |  | （請求が発生した場合）支払期限日 |
| `payment_completion_date` | string |  | （請求が発生した場合）請求日 |
| `status_code` | DepositStatusCode |  |  |
| `count` | integer |  | この売上入金に含まれる売上入金詳細の件数 |
| `settlement_amount` | integer(int64) |  | この売上入金において精算の対象となった取引の総額。 |
| `bank_transfer_fee` | integer(int64) |  | 振込手数料 |
| `total_amount` | integer(int64) |  | この売上入金において精算の対象となった取引の総額。 |
| `fee_amount` | integer(int64) |  | この売上入金において精算の対象となった取引にかかるM's PayBridgeへの手数料 |
| `taxable_fee_amount` | integer(int64) |  | 課税対象手数料 |
| `nontaxable_fee_amount` | integer(int64) |  | 非課税手数料 |
| `web_registration_fee_amount` | integer(int64) |  | この売上入金の精算期間中に発生した振替口座のWeb登録手数料 |
| `paper_registration_fee_amount` | integer(int64) |  | この売上入金の精算期間中に発生した振替口座の依頼書登録手数料 |
| `tax_amount` | integer(int64) |  | この売上入金において精算の対象となった取引にかかるM's PayBridgeへの手数料にかかる消費税 |
| `platform_fee_amount` | integer(int64) |  | この売上入金において精算の対象となった取引にかかるプラットフォーム利用料 |
| `platform_fee_tax_amount` | integer(int64) |  | この売上入金において精算の対象となった取引にかかるプラットフォーム利用料の消費税 |
| `platform_web_registration_fee_amount` | integer(int64) |  | 売上入金 精算期間中に発生した、プラットフォームが設定した振替口座のWeb登録手数料 |
| `platform_paper_registration_fee_amount` | integer(int64) |  | 売上入金 精算期間中に発生した、プラットフォームが設定した振替口座の依頼書登録手数料 |
| `created` | created |  |  |
| `updated` | updated |  |  |
| `deposit_destination` | DepositTargetBankAccountInfo |  | 売上入金 入金先口座情報 |

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

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

