# テナントバイヤー 本番環境申請

`POST /v1/buyer/contracts/examinations`

- operationId: `requestBuyerProductionEnvironment`
- tags: テナントバイヤー申請管理

`id`で指定したテナントバイヤーの本番環境の利用申請を行います。このAPIを呼び出すまでにテナントバイヤー本番環境申請情報 更新APIで申請情報を用意しておく必要があります。


## コードサンプル

### cURL

```bash
curl \
    -X POST \
    -H "Authorization:Bearer <Secret API Key>" \
    -H "Content-Type: application/json" \
    -H "Tenant-Buyer-Id: <Tenant Buyer ID>" \
    -d '{
    "buyer_id": "<Buyer ID>",
    "force_credit_check_skip": false
}' \
'https://api.test.fincode.jp/v1/buyer/contracts/examinations'
```

### Node.js

```javascript
const API_KEY = "<Secret API Key>";
const TENANT_BUYER_ID = "<Tenant Buyer ID>";
const BUYER_ID = "<Buyer ID>";

(async () => {
  try {
    const response = await fetch(
      "https://api.test.fincode.jp/v1/buyer/contracts/examinations",
      {
        method: "POST",
        headers: {
          Authorization: `Bearer ${API_KEY}`,
          "Tenant-Buyer-Id": TENANT_BUYER_ID,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          buyer_id: BUYER_ID,
          force_credit_check_skip: false,
        }),
      }
    );

    const data = await response.json();
    console.log(data);
  } catch (e) {
    console.error(e);
  }
})();
```

### Go

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
)

func main() {

	apiKey := "<Secret API Key>"

	tenantBuyerID := "<Tenant Buyer ID>"

	body := RequestExaminationRequestBody{
		BuyerID:             "<Buyer ID>",
		EnableImmediateUse: false,
	}

	marshalledBody, _ := json.Marshal(body)

	// リクエストの作成
	req, _ := http.NewRequest("POST", "https://api.test.fincode.jp/v1/buyer/contracts/examinations", bytes.NewBuffer(marshalledBody))
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Tenant-Buyer-Id", tenantBuyerID)

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

}

type RequestExaminationRequestBody struct {
	BuyerID             string `json:"buyer_id"`
	EnableImmediateUse bool   `json:"enable_immediate_use"`
}
```

### PHP

```php
<?php

$apiKey = '<Secret API Key>';

$tenantBuyerId = '<Tenant Buyer ID>';

$baseUrl = "https://api.test.fincode.jp";
$endpoint = "/v1/buyer/contracts/examinations";
$headers = [
    "Authorization: Bearer " . $apiKey,
    "Content-Type: application/json",
    "Tenant-Buyer-Id: " . $tenantBuyerId,
];

$data = json_encode([
    "buyer_id" => "b_***********",
    "force_credit_check_skip" => "false",
]);

$session = curl_init();
curl_setopt($session, CURLOPT_URL, $baseUrl . $endpoint);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $data);
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>'

tenant_buyer_id = '<Tenant Buyer ID>'
url = f'https://api.test.fincode.jp/v1/buyer/contracts/examinations'

# ヘッダーを設定
headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json',
    'Tenant-Buyer-Id': tenant_buyer_id,
}

data = {
    "buyer_id": "<Buyer ID>",
    "force_credit_check_skip": "false",
}

# HTTP POSTリクエストの送信
try:
    response = requests.post(url, headers=headers, json=data)

    # レスポンスの処理
    if response.status_code == 200:
        # 成功した場合の処理
        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
    tenant_buyer_id = '<Tenant Buyer ID>'

    endpoint = "/v1/buyer/contracts/examinations"
    uri = URI.parse(BASE_URL + endpoint)

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

    data = {
        buyer_id: '<Buyer ID>',
        force_credit_check_skip: false,
    }

    # リクエストの作成
    request = Net::HTTP::Post.new(uri.request_uri)
    request['Authorization'] = "Bearer #{API_KEY}"
    request['Content-Type'] = 'application/json'
    request['Tenant-Buyer-Id'] = tenant_buyer_id

    request.body = data.to_json

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

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

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

main
```

## パラメータ

| 名前 | 位置 | 必須 | 型 | 説明 |
| --- | --- | --- | --- | --- |
| `Tenant-Buyer-Id` | header | ✓ | schema | <span class="smallText color--red-400">※ プラットフォームのメインショップのみ指定可</span> |

## リクエストボディ

Content-Type: `multipart/form-data`

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `buyer_id` | buyer_id | ✓ |  |
| `force_credit_check_skip` | boolean | ✓ | 信用情報チェックを強制的にスキップする。 |

## レスポンス

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

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `buyer_id` | buyer_id |  | バイヤーID |
| `status_code` | enum(1 | 2 | 3) |  | 申請ステータス |

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

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

