【问题标题】:How can I get the logo for an "Item" from the Plaid api?如何从 Plaid api 获取“项目”的徽标?
【发布时间】:2017-10-05 02:44:34
【问题描述】:

我查看了 API 文档,但没有看到任何关于如何获取徽标的信息,但 plaid 显然有它们,因为它们出现在链接应用程序中。作为 API 的一部分或通过使用“项目”ID 的其他机制,我是否也可以通过任何方式访问这些徽标?

【问题讨论】:

    标签: plaid


    【解决方案1】:

    虽然在撰写本文时没有记录,但显然可以通过将选项参数添加到值为 {"include_display_data": true} 的机构请求中来完成。使用 getInstitutionById 方法和 Vangaurd 的节点 API 看起来像这样。

    client.getInstitutionById('ins_108768', {include_display_data: true} (err, result) => {
     // Handle err
     const logo = result.institution.logo;
    });
    

    logo 的值为 null 或包含 logo 二进制数据的 base64 编码字符串。

    【讨论】:

    • 这是旧 API 版本吗?我在访问 /institutions/get_by_id 时收到“此端点无法识别以下字段:选项”
    • 这是一个获取徽标请求的 curl 示例。 (设置自己的公钥)curl -X POST https://sandbox.plaid.com/institutions/get_by_id \ -H 'Content-Type: application/json' \ -d '{ "institution_id": "ins_108968", "public_key": "YOUR_PUBLIC_KEY", "options": { "include_display_data": true} }'
    【解决方案2】:

    当前版本的格子 ruby​​ gem(6.1.0) 不检索徽标,但您可以扩展格子库并使用 include_display_data 参数获取徽标。

    module Plaid
      class Institutions < BaseProduct
    
        def get_by_id_with_logo(institution_id)
          post_with_public_key 'institutions/get_by_id',
                               SingleInstitutionResponse,
                               institution_id: institution_id,
                               options: { include_display_data: true }
        end
      end
    end
    

    用法:

    ins = client.institutions.get_by_id_with_logo(YOUR_INSTITUTION_ID)
    puts ins.institution[:logo]
    

    【讨论】:

      【解决方案3】:

      要从 Plaid API 获取所有机构的列表,需要使用 POST 请求点击/institutions/get。要获取徽标和其他机构属性,例如主页 URL 和品牌颜色,需要在请求正文中添加 options 属性,其中键=>值对“include_optional_metadata”=> true。 count 参数表示要返回的机构数(perPage),而 offset 是要跳过的机构数。

      curl -X POST \
      https://sandbox.plaid.com/sandbox/institutions/get \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
              "client_id": "clientIdFromPlaidDashboard",
              "secret": "secretFromPlaidDashboard",
              "count": 500,
              "offset": 0,
              "options" => [
                  "include_optional_metadata" => true
               ]
          }'
      

      来自 Plaid doc 的预期响应:

      http code 200
      {
        "institutions": [
          {
            "country_codes": ["US"],
            "credentials": [{
              "label": "User ID",
              "name": "username",
              "type": "text"
             }, {
              "label": "Password",
              "name": "password",
              "type": "password"
            }],
            "has_mfa": true,
            "institution_id": "ins_109508",
            "mfa": [
              "code",
              "list",
              "questions",
              "selections"
            ],
            "name": "First Platypus Bank",
            // the following are included when
            // options.include_optional_metadata is true
            "primary_color": "#1f1f1f",
            "url": "https://plaid.com",
            "logo": null,
            ]
          }
        ],
        "request_id": "m8MDnv9okwxFNBV",
        "total": 1
      }
      

      【讨论】:

        猜你喜欢
        • 2023-03-15
        • 1970-01-01
        • 2021-10-16
        • 1970-01-01
        • 2018-02-06
        • 1970-01-01
        • 2016-05-16
        • 2011-05-08
        • 2021-11-22
        相关资源
        最近更新 更多