Cartão de Crédito (CreditCard)

Listar Cartões de Crédito

GET /entities/:entity_id/credit_cards

Retorna 200 OK e uma lista de cartões de crédito.

Exemplo de Resposta

HTTP/1.1 200 OK
Date: Mon, 17 Jan 2011 20:00:02 GMT
Content-Type: application/json; charset=utf-8
[
  {
    "credit_card": {
      "id": 1,
      "name": "Cartão 1",
      "flag": "MasterCard",
      "closing_day": 20,
      "expiration_day": 02,
      "entity_id": 1,
      "category_id": null,
      "person_id": null,
      "classification_center_id": null,
      "flag_image_url": "https://app.myfinance.com.br/assets/logos/logo-creditcard-mastercard.png",
      "observation": null,
      "custom_classifications": [
        {
          "id": 1,
          "custom_classifier_id": 1,
          "custom_classifier_name": "Produto",
          "value": "Cobrato", # DEPRECATED
          "name": "Cobrato",
          "amount": 36.0,
          "percentage": 100.0
        }
      ],
      "classification_center_classifications":[
        {
          id: "1",
          classification_center_id: 1,
          name: "Cobrato",
          percentage: "100.0",
          amount: "36.0"
        }
      ],
      "links": [
        {
          "rel": "self",
          "href": "https://app.myfinance.com.br/entities/1/credit_cards/1",
          "method": "get"
        }
      ]
    }
  },
  {
    "tax": {
      "id": 2,
      "name": "Cartão 2",
      "flag": "Visa",
      "closing_day": 23,
      "expiration_day": 05,
      "entity_id": 1,
      "category_id": null,
      "person_id": null,
      "classification_center_id": null,
      "flag_image_url": "https://app.myfinance.com.br/assets/logos/logo-creditcard-visa.png",
      "observation": null,
      "links": [
        {
          "rel": "self",
          "href": "https://app.myfinance.com.br/entities/1/credit_cards/2",
          "method": "get"
        }
      ]
    }
  }
]
HTTP/1.1 200 OK
Date: Mon, 17 Jan 2011 20:00:02 GMT
Content-Type: application/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
  <credit-cards type="array">
    <credit-card>
      <id type="integer">1</id>
      <name>Cartão 1</name>
      <flag>MasterCard</flag>
      <closing-day type="integer">20</closing-day>
      <expiration-day type="integer">02</expiration-day>
      <entity-id type="integer">1</entity-id>
      <flag-image-url>https://app.myfinance.com.br/assets/logos/logo-creditcard-mastercard.png</flag-image-url>
      <observation nil="true" />
      <custom-classifications type="array">
        <custom-classification>
          <id type="integer">1</id>
          <custom-classifier-id type="integer">1</custom-classifier-id>
          <custom-classifier-name>Região</custom-classifier-name>
          <value>Cobrato</value> # DEPRECATED
          <name>Cobrato</name>
          <percentage type="decimal">100.0</percentage>
          <amount type="decimal">36.0</amount>
        </custom-classification>
      </custom-classifications>
      <classification-center-classifications type="array">
        <classification-center-classification>
          <id type="integer">1</id>
          <classification-center-id type="integer">1</classification-center-id>
          <name>Cobrato</name>
          <percentage type="decimal">100.0</percentage>
          <amount type="decimal">36.0</amount>
        </classification-center-classification>
      </classification-center-classifications>
      <links type="array">
        <link>
          <rel>self</rel>
          <href>https://app.myfinance.com.br/entities/1/credit_cards/1</href>
          <method>get</method>
        <link>
      </links>
    </credit-card>
  </credit-cards>

Exibir um Cartão de Crédito

GET /entities/:entity_id/credit_cards/:id

Retorna 200 OK e os dados do cartão de crédito solicitado.

Exemplo de Resposta

HTTP/1.1 200 OK
Date: Mon, 17 Jan 2011 20:00:02 GMT
Content-Type: application/json; charset=utf-8
{
  "credit_card": {
    "id": 1,
    "name": "Cartão 1",
    "flag": "MasterCard",
    "closing_day": 20,
    "expiration_day": 02,
    "entity_id": 1,
    "category_id": null,
    "person_id": null,
    "classification_center_id": null,
    "flag_image_url": "https://app.myfinance.com.br/assets/logos/logo-creditcard-mastercard.png",
    "observation": null,
    "custom_classifications": [
      {
        "id": 1,
        "custom_classifier_id": 1,
        "custom_classifier_name": "Produto",
        "value": "Cobrato", # DEPRECATED
        "name": "Cobrato",
        "amount": 36.0,
        "percentage": 100.0
      }
    ],
    "classification_center_classifications":[
      {
        id: "1",
        classification_center_id: 1,
        name: "Cobrato",
        percentage: "100.0",
        amount: "36.0"
      }
    ],
    "links": [
      {
        "rel": "self",
        "href": "https://app.myfinance.com.br/entities/1/credit_cards/1",
        "method": "get"
      }
    ]
  }
}
HTTP/1.1 200 OK
Date: Mon, 17 Jan 2011 20:00:02 GMT
Content-Type: application/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
  <credit-card>
    <id type="integer">1</id>
    <name>Cartão 1</name>
    <flag>MasterCard</flag>
    <closing-day>20</closing-day>
    <expiration-day>02</expiration-day>
    <entity-id type="integer">1</entity-id>
    <category-id nil="true" />
    <person-id nil="true" />
    <classification-center-id nil="true" />
    <flag-image-url>https://app.myfinance.com.br/assets/logos/logo-creditcard-mastercard.png</flag-image-url>
    <observation nil="true" />
    <custom-classifications type="array">
      <custom-classification>
        <id type="integer">1</id>
        <custom-classifier-id type="integer">1</custom-classifier-id>
        <custom-classifier-name>Região</custom-classifier-name>
        <value>Cobrato</value> # DEPRECATED
        <name>Cobrato</name>
        <percentage type="decimal">100.0</percentage>
        <amount type="decimal">36.0</amount>
      </custom-classification>
    </custom-classifications>
    <classification-center-classifications type="array">
      <classification-center-classification>
        <id type="integer">1</id>
        <classification-center-id type="integer">1</classification-center-id>
        <name>Cobrato</name>
        <percentage type="decimal">100.0</percentage>
        <amount type="decimal">36.0</amount>
      </classification-center-classification>
    </classification-center-classifications>
    <links type="array">
      <link>
        <rel>self</rel>
        <href>https://app.myfinance.com.br/entities/1/credit_cards/1</href>
        <method>get</method>
      <link>
    </links>
  </credit-card>

Criar um Cartão de Crédito

POST /entities/:entity_id/credit_cards

Cria um novo cartão de crédito com os parâmetros passados. Em caso de sucesso, retorna 201 Created, juntamente com a URI do cartão de crédito criado no cabeçalho Location da resposta HTTP. Em caso de falha, retorna 422 Unprocessable entity juntamente com a descrição dos erros.

Exemplo de Requisição

{
  "credit_card": {
    "name": "Cartão 1",
    "flag": "MasterCard",
    "closing_day": 20,
    "expiration_day": 02,
    "category_id": 2,
    "person_id": 5,
    "classification_center_id": 20,
    "custom_classifications": [
      {
        "custom_classifier_id": 1,
        "name": "Sudeste",
        "amount": 36.0
      }
    ],
    "classification_center_classifications":[
      {
        classification_center_id: 1,
        name: "Sudeste",
        amount: "36.0"
      }
    ],
  }
}
<credit-card>
  <name>Cartão 1</name>
  <flag>MasterCard</flag>
  <closing-day type="integer">20</closing-day>
  <expiration-day type="integer">02</expiration-day>
  <category-id type="integer">2</category-id>
  <person-id type="integer">5</person-id>
  <classification-center-id type="integer">5</classification-center-id>
  <custom-classifications type="array">
    <custom-classification>
      <custom-classifier-id>1</custom-classifier-id>
      <name>Zona Sul</name>
      <amount type="decimal">36.0</amount>
    </custom-classification>
  </custom-classifications>
  <classification-center-classifications type="array">
    <classification-center-classification>
      <classification-center-id type="integer">1</classification-center-id>
      <name>Zona Sul</name>
      <amount type="decimal">36.0</amount>
    </classification-center-classification>
  </classification-center-classifications>
</credit-card>

Exemplo de Resposta

HTTP/1.1 201 Created
Location: https://app.myfinance.com.br/entities/1/credit_cards
Content-Type: application/json; charset=utf-8
Date: Wed, 26 Jan 2011 13:27:00 GMT
{
  "credit_card": {
    "id": 1,
    "name": "Cartão 1",
    "flag": "MasterCard",
    "closing_day": 20,
    "expiring_day": 02,
    "entity_id": 1,
    "category_id": 2,
    "person_id": 5,
    "classification_center_id": 20,
    "custom_classifications": [
      {
        "id": 27,
        "custom_classifier_id": 1,
        "custom_classifier_name": "Região",
        "value": "Sudeste", # DEPRECATED
        "name": "Sudeste",
        "amount": null,
        "percentage": 100
      }
    ],
    "classification_center_classifications":[
      {
        id: "1",
        classification_center_id: 1,
        name: "Cobrato",
        percentage: "100.0",
        amount: "36.0"
      }
    ],
    "flag_image_url": "https://app.myfinance.com.br/assets/logos/logo-creditcard-mastercard.png",
    "links": [
      {
        "rel": "self",
        "href": "https://app.myfinance.com.br/entities/1/credit_cards/1",
        "method": "get"
      }
    ]
  }
}
HTTP/1.1 201 Created
Location: https://app.myfinance.com.br/entities/1/credit_cards
Content-Type: application/xml; charset=utf-8
Date: Wed, 26 Jan 2011 13:27:00 GMT
<?xml version="1.0" encoding="UTF-8"?>
<credit-card>
  <id type="integer">1</id>
  <name>Cartão 1</name>
  <flag>MasterCard</flag>
  <closing-day type="integer">20</closing-day>
  <expiration-day type="integer">02</expiration-day>
  <entity-id type="integer">1</entity-id>
  <category-id type="integer">2</category-id>
  <person-id type="integer">5</person-id>
  <classification-center-id type="integer">20</classification-center-id>
  <custom-classifications type="array">
    <custom-classification>
      <id type="integer">24</id>
      <custom-classifier-id type="integer">1</custom-classifier-id>
      <custom-classifier-name>Região</custom-classifier-name>
      <name>Sudeste</name>
      <amount nil="true"/>
      <percentage>100</percentage>
    </custom-classification>
  </custom-classifications>
  <classification-center-classifications type="array">
    <classification-center-classification>
      <id type="integer">1</id>
      <classification-center-id type="integer">1</classification-center-id>
      <name>Cobrato</name>
      <percentage type="decimal">100.0</percentage>
      <amount type="decimal">36.0</amount>
    </classification-center-classification>
  </classification-center-classifications>
  <flag-image-url>https://app.myfinance.com.br/assets/logos/logo-creditcard-mastercard.png</flag-image-url>
  <links type="array">
    <link>
      <rel>self</rel>
      <href>https://app.myfinance.com.br/entities/1/credit_cards/1</href>
      <method>get</method>
    <link>
  </links>
</credit-card>

Atualizar um Cartão de Crédito

PUT /entities/:entity_id/credit_cards/:id

Atualiza um novo cartão de crédito com os parâmetros passados. Em caso de sucesso, retorna 200 OK, juntamente com a URI do cartão de crédito atualizado no cabeçalho Location da resposta HTTP. Em caso de falha, retorna 422 Unprocessable entity juntamente com a descrição dos erros.

Exemplo de Requisição

{
  "credit_card": {
    "id": 1,
    "name": "Cartão 1",
    "flag": "MasterCard",
    "closing_day": 20,
    "expiration_day": 02,
    "entity_id": 1
  }
}
<credit-card>
  <id type="integer">1</id>
  <name>Cartão 1</name>
  <flag>MasterCard</flag>
  <closing-day type="integer">20</closing-day>
  <expiration-day type="integer">02</expiration-day>
  <entity-id type="integer">1</entity-id>
</credit-card>

Exemplo de Resposta

HTTP/1.1 200 OK
Location: https://app.myfinance.com.br/entities/1/credit_cards/1
Content-Type: application/json; charset=utf-8
Date: Wed, 26 Jan 2011 13:27:00 GMT
{
  "credit_card": {
    "id": 1,
    "name": "Cartão 1",
    "flag": "MasterCard",
    "closing_day": 20,
    "expiring_day": 02,
    "entity_id": 1,
    "category_id": null,
    "person_id": null,
    "classification_center_id": null,
    "links": [
      {
        "rel": "self",
        "href": "https://app.myfinance.com.br/entities/1/credit_cards/1",
        "method": "get"
      }
    ]
  }
}
HTTP/1.1 200 OK
Location: https://app.myfinance.com.br/entities/1/credit_cards/1
Content-Type: application/xml; charset=utf-8
Date: Wed, 26 Jan 2011 13:27:00 GMT
<?xml version="1.0" encoding="UTF-8"?>
<credit-card>
  <id type="integer">1</id>
  <name>Cartão 1</name>
  <flag>MasterCard</flag>
  <closing-day type="integer">20</closing-day>
  <expiration-day type="integer">02</expiration-day>
  <entity-id type="integer">1</entity-id>
  <category-id nil="true" />
  <person-id nil="true" />
  <classification-center-id nil="true" />
  <links type="array">
    <link>
      <rel>self</rel>
      <href>https://app.myfinance.com.br/entities/1/credit_cards/1</href>
      <method>get</method>
    <link>
  </links>
</credit-card>

Apagar um Cartão de Crédito

Exemplo de Requisição

DELETE /entities/:entity_id/credit_cards/:id

Apaga o cartão de crédito especificado, retornando uma resposta vazia com status 200 Ok. Em caso de sucesso, todos os recursos previamente associados ao cartão de crédito apagado serão também excluídos.