Skip to content

Instantly share code, notes, and snippets.

@dmsysop
Created January 25, 2020 01:33
Show Gist options
  • Save dmsysop/490c12116948e36a23fb4e31333b69bc to your computer and use it in GitHub Desktop.
Save dmsysop/490c12116948e36a23fb4e31333b69bc to your computer and use it in GitHub Desktop.
Zoop Users API
swagger: '2.0'
host: api.zoop.ws
info:
title: Usuários e API Keys
version: "1.1"
securityDefinitions:
basicAuth:
type: basic
security:
- basicAuth: []
schemes:
- https
tags:
- name: 'Usuário'
description: Usuários de acesso a API
- name: 'API Key'
description: Chaves de acesso a API
- name: 'Marketplace'
description: Criação de marketplaces
paths:
'/users/{user_id}/permissions':
parameters:
- $ref: '#/parameters/userIdParam'
get:
tags:
- Usuário
summary: Permissão do usuário
operationId: permissions_get
description: |
Busca todas as permissões que usuário possui pelo user_id
parameters:
- $ref: '#/parameters/limitParam'
- $ref: '#/parameters/sortParam'
- $ref: '#/parameters/offsetParam'
- $ref: '#/parameters/dateRangeParam'
- $ref: '#/parameters/dateRangeGTParam'
- $ref: '#/parameters/dateRangeGTEParam'
- $ref: '#/parameters/dateRangeLTParam'
- $ref: '#/parameters/dateRangeLTEParam'
responses:
200:
description: Permissions the user_id
schema:
$ref: '#/definitions/PermissionResponse'
404:
description: user_id not found
post:
tags:
- Usuário
summary: Criar permissão para usuário
operationId: permissions_post
description: |
Cria uma nova permissão para o usuário, podendo vincular à marketplace, seller ou grupo
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: permission
description: criar uma nova permissão para usuário
schema:
$ref: '#/definitions/PermissionRequest'
responses:
201:
description: New permission created
schema:
$ref: '#/definitions/UserPermissioResponse'
400:
description: invalid input, object invalid
409:
description: an item already exists
'/users/{user_id}/permissions/{permission_id}':
parameters:
- $ref: '#/parameters/userIdParam'
- $ref: '#/parameters/permissionIdParam'
get:
tags:
- Usuário
summary: Permissão do usuário por permission_id
operationId: permissions_id_get
description: |
Permissões que usuário possui pelo permission_id
produces:
- application/json
responses:
200:
description: Permission the permission_id
schema:
$ref: '#/definitions/UserPermissioResponse'
404:
description: permission_id or user_id not found
delete:
tags:
- Usuário
summary: deleta uma permissão
operationId: permissions_id_delete
description: Remove uma permissões do usuário pelo permission_id
consumes:
- application/json
produces:
- application/json
parameters:
- $ref: '#/parameters/userIdParam'
- $ref: '#/parameters/permissionIdParam'
responses:
200:
description: Permission deleted
404:
description: permission_id not found
'/v1/marketplaces/{marketplace_id}/users':
parameters:
- name: marketplace_id
in: path
description: identificador do marketplace
required: true
type: string
post:
tags:
- 'Usuário'
summary: 'Criar novo usuário de API por marketplace'
description: ''
operationId: users_marketplace_post
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: User request object
required: true
schema:
$ref: '#/definitions/UserRequest'
responses:
'200':
description: Usuário criado com sucesso
schema:
$ref: '#/definitions/UserResponse'
'/v1/users':
post:
tags:
- 'Usuário'
summary: 'Criar novo usuário de API'
description: ''
security: []
operationId: users_post
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: User request object
required: true
schema:
$ref: '#/definitions/UserRequest'
responses:
'200':
description: Usuário criado com sucesso
schema:
$ref: '#/definitions/UserResponse'
'/v1/users/signin':
post:
tags:
- 'Usuário'
summary: 'Relizar login por usuário/senha'
description: ''
security: []
operationId: users_signin
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: User request object
required: true
schema:
$ref: '#/definitions/UserSigninRequest'
responses:
'200':
description: Usuário logado com sucesso
schema:
$ref: '#/definitions/UserResponse'
'401':
description: Usuário ou senha inválido
'/v1/users/{user_id}':
parameters:
- name: user_id
in: path
description: identificador do usuário
required: true
type: string
put:
tags:
- 'Usuário'
summary: 'Alterar detalhes de usuário'
description: ''
operationId: users_put
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: User request object
required: true
schema:
$ref: '#/definitions/UserUpdateRequest'
responses:
'200':
description: Usuário alterado com sucesso
schema:
$ref: '#/definitions/UserResponse'
get:
tags:
- 'Usuário'
summary: 'Recuperar detalhes de usuário'
description: ''
operationId: users_id_put
produces:
- application/json
responses:
'200':
description: Usuário recuperado com sucesso
schema:
$ref: '#/definitions/UserResponse'
delete:
tags:
- 'Usuário'
summary: 'Remover usuário'
description: ''
operationId: users_id_delete
produces:
- application/json
responses:
'200':
description: Usuário removido com sucesso
'/v1/marketplaces/{marketplace_id}/api_keys':
parameters:
- name: marketplace_id
in: path
description: identificador do marketplace
required: true
type: string
post:
tags:
- 'API Key'
summary: 'Criar nova API Key por marketplace'
description: ''
operationId: apikeys_post
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Chave de API
required: true
schema:
$ref: '#/definitions/ApiKeyRequest'
responses:
'200':
description: Chave de API criado com sucesso
schema:
$ref: '#/definitions/ApiKeyResponse'
get:
tags:
- 'API Key'
summary: 'Listar chaves de API por marketplace'
description: ''
operationId: apikeys_get
parameters:
- $ref: '#/parameters/limitParam'
- $ref: '#/parameters/sortParam'
- $ref: '#/parameters/offsetParam'
- $ref: '#/parameters/dateRangeParam'
- $ref: '#/parameters/dateRangeGTParam'
- $ref: '#/parameters/dateRangeGTEParam'
- $ref: '#/parameters/dateRangeLTParam'
- $ref: '#/parameters/dateRangeLTEParam'
produces:
- application/json
responses:
'200':
description: API Key recuperada com sucesso
schema:
$ref: '#/definitions/ApiKeysList'
'/v1/marketplaces/{marketplace_id}/api_keys/{apikey_id}':
parameters:
- name: marketplace_id
in: path
description: identificador do marketplace
required: true
type: string
- name: apikey_id
in: path
description: identificador do api key
required: true
type: string
get:
tags:
- 'API Key'
summary: 'Recuperar detalhes de um API Key'
description: ''
operationId: apikeys_id_get
produces:
- application/json
responses:
'200':
description: Chave de API recuperado com sucesso
schema:
$ref: '#/definitions/ApiKeyResponse'
delete:
tags:
- 'API Key'
summary: 'Remover API Key'
description: ''
operationId: apikeys_id_delete
produces:
- application/json
responses:
'200':
description: API Key recuperada com sucesso
'/v1/marketplaces':
post:
tags:
- 'Marketplace'
summary: 'Criar novo marketplace'
description: ''
operationId: marketplaces_post
consumes:
- application/json
produces:
- application/json
responses:
'200':
description: Marketplace criado com sucesso
'400':
description: Requisição inválida
'/v1/marketplaces/{marketplace_id}':
parameters:
- name: marketplace_id
in: path
description: identificador do marketplace
required: true
type: string
get:
tags:
- 'Marketplace'
summary: 'Recuperar detalhes do marketplace'
description: ''
operationId: marketplaces_get
produces:
- application/json
responses:
'200':
description: Marketplace criado com sucesso
schema:
example: |
{
"id": "3249465a7753536b62545a6a684b0000",
"resource": "marketplace",
"name": "Zoop Test Marketplace",
"type": "business_test",
"description": "Zoop test marketplace",
"is_active": true,
"is_verified": true,
"account_balance": "2422678.30",
"current_balance": "0.00",
"decline_on_fail_security_code": false,
"decline_on_fail_zip_code": false,
"support_email": "[email protected]",
"phone_number": "2024356789",
"statement_descriptor": "Zoop Inc.",
"website": "http://getzoop.com",
"facebook": "http://facebook.com/getzoop",
"twitter": "http://twitter.com/getzoop",
"customer": {
"id": "c7e3cb5fcb724201ad0925e29004df1b",
"status": "active",
"resource": "seller",
"type": "business",
"description": null,
"account_balance": "0.00",
"current_balance": "0.00",
"business_name": "Zoop Inc",
"business_phone": " 12026256754",
"business_email": "[email protected]",
"business_website": "https://pagzoop.com",
"business_description": "The open mobile payment platform",
"business_opening_date": null,
"business_facebook": "http://fb.com/getzoop",
"business_twitter": "http://twitter.com/getzoop",
"ein": "253912384",
"statement_descriptor": null,
"mcc": null,
"business_address": {
"line1": "167 West 74th Street",
"line2": null,
"line3": null,
"neighborhood": null,
"city": "Washington",
"state": null,
"postal_code": "10023",
"country_code": "US"
},
"owner": {
"first_name": "Fabiano",
"last_name": "Cruz",
"email": "[email protected]",
"phone_number": " 12029579543",
"taxpayer_id": null,
"birthdate": "1982-12-15",
"address": {
"line1": null,
"line2": null,
"line3": null,
"neighborhood": null,
"city": null,
"state": null,
"postal_code": null,
"country_code": null
}
},
"show_profile_online": false,
"is_mobile": false,
"decline_on_fail_security_code": false,
"decline_on_fail_zipcode": false,
"delinquent": false,
"payment_methods": null,
"default_debit": null,
"default_credit": null,
"merchant_code": "012000000000001",
"terminal_code": "GT0000CA",
"uri": "/v1/marketplaces/3249465a7753536b62545a6a684b0000/sellers/businesses/c7e3cb5fcb724201ad0925e29004df1b",
"metadata": {},
"created_at": "2014-03-28T05:52:08+00:00",
"updated_at": "2014-11-26T04:15:00+00:00"
},
"api_keys": [
{
"id": "7705b333cb884d099d94df43009ad515",
"resource": "api_key",
"type": "test_key",
"name": null,
"test_key": "************",
"publishable_test_key": "zpk_test_EzCkzFFKibGQU6HFq7EYVuxI",
"production_key": null,
"publishable_production_key": null,
"uri": "/v1/marketplaces/3249465a7753536b62545a6a684b0000/api_keys/7705b333cb884d099d94df43009ad515",
"metadata": {},
"created_at": "1970-01-01T00:00:00+00:00",
"updated_at": "1970-01-01T00:00:00+00:00"
}
],
"transfer_enabled": true,
"transfer_policy": "daily",
"debit_enabled": true,
"default_debit": null,
"default_credit": null,
"uri": "/v1/marketplaces/3249465a7753536b62545a6a684b0000",
"created_at": "2013-07-31T11:00:00+00:00",
"updated_at": "2017-07-11T15:19:19+00:00",
"metadata": []
}
'404':
description: Marketplace não encontrado
definitions:
PermissionResponse:
type: object
properties:
resource:
type: string
example: "permissions"
uri:
type: string
example: "/v1/users/d6cf41c2-caa1-4e54-a170-ba078f5dfe53/permissions"
limit:
type: number
example: 100
offset:
type: number
example: 0
has_more:
type: boolean
example: false
query_count:
type: number
example: 2
total:
type: number
example: 2
user_id:
type: string
example: c6cf41c2-caa1-4e54-a170-ba078f5dfe53
items:
type: array
items:
$ref: '#/definitions/UserPermissioResponse'
PermissionRequest:
type: object
required:
- user
- service
- action
- resource
properties:
user:
description: ID do usuário
type: string
example: d6cf41c2-caa1-4e54-a170-ba078f5dfe53
marketplace:
description: ID do marketplace
type: string
example: f6cf41c2-caa1-4e54-a170-ba078f5dfe53
customer:
description: ID do customer
type: string
example: e6cf41c2-caa1-4e54-a170-ba078f5dfe53
service:
description: Nome do serviço para qual irá criar permissão
type: string
example: "buyers"
resource:
description: recurso do serviço para qual irá criar permissão
type: string
example: "individuals"
action:
type: string
description: Tipo de ações que a permissão irá permitir
example: "GET"
UserRequest:
type: object
required:
- email
- username
- password
properties:
email:
description: E-mail do usuário
type: string
first_name:
description: Primeiro nome do usuário
type: string
last_name:
description: Primeiro nome do usuário
type: string
username:
description: Identificador do usuário utilizado no login
type: string
password:
description: Senha do usuário utilizado no login
type: string
metadata:
type: object
UserUpdateRequest:
type: object
properties:
email:
description: E-mail do usuário
type: string
username:
description: Identificador do usuário utilizado no login
type: string
password:
description: Senha do usuário utilizado no login
type: string
UserResponse:
type: object
properties:
id:
type: string
example: 4B53764E831B48BA8F65B70B525C3A5C
resource:
type: string
example: "user"
token:
description: User Token API à ser utilizado nas requisições
type: string
example: "N2JlODhhMzItY2VkNy00NTM1LWIzMTItODZhNmVmOGUwMzMx"
email:
description: E-mail do usuário
type: string
example: "[email protected]"
first_name:
description: Primeiro nome do usuário
type: string
example: Joao
last_name:
description: Primeiro nome do usuário
type: string
example: Das Neves
username:
description: Identificador do usuário utilizado no login
type: string
example: "[email protected]"
created_at:
type: string
format: dateTime
example: "2015-04-17T06:39:52+00:00"
updated_at:
type: string
format: dateTime
example: "2015-04-17T06:39:52+00:00"
uri:
type: string
example: /v1/users/4B53764E831B48BA8F65B70B525C3A5C
UserSigninRequest:
type: object
required:
- username
- password
properties:
username:
description: Identificador do usuário utilizado no login
type: string
password:
description: Senha do usuário utilizado no login
type: string
ApiKeyRequest:
type: object
required:
- name
properties:
name:
description: Nome da chave de acesso a API
type: string
metadata:
type: object
ApiKeyResponse:
type: object
properties:
id:
type: string
example: 7705b333cb884d099d94df43009ad515
resource:
type: string
example: "api_key"
type:
description: Tipo da chave
type: string
enum:
- test_key
- production_key
name:
description: Nome da chave
type: string
example: Integração
test_key:
description: Chave de teste privada
type: string
example: "*********"
publishable_test_key:
description: Chave de teste pública
type: string
example: zpk_test_EzCkzFFKibGQU6HFq7EYVuxI
production_key:
description: Chave produção privada
type: string
publishable_production_key:
description: Chave produção pública
type: string
metadata:
type: object
created_at:
type: string
format: dateTime
example: "2015-04-17T06:39:52+00:00"
updated_at:
type: string
format: dateTime
example: "2015-04-17T06:39:52+00:00"
uri:
type: string
example: /v1/marketplaces/3249465a7753536b62545a6a684b0000/api_keys/7705b333cb884d099d94df43009ad515
ApiKeysList:
type: object
properties:
resource:
type: string
example: "list"
uri:
type: string
example: "/v1/marketplaces/820a6bda73c546a8b2f12a5ebcae7732/api_keys"
limit:
type: number
example: 100
offset:
type: number
example: 0
has_more:
type: boolean
example: false
query_count:
type: number
example: 2
total:
type: number
example: 2
items:
$ref: '#/definitions/ApiKeyResponse'
UserPermissioResponse:
type: object
properties:
id:
type: string
example: a6cf41c2caa14e54a170-ba078f5dfe53
hash:
type: string
description: acl:client:marketplace_id:seller_id:service:resource:action
example: client:a6cf41c2-caa1-4e54-a170-ba078f5dfe53:c6cf41c2-caa1-4e54-a170-ba078f5dfe53:buyers:individuals:GET
user:
description: ID do usuário
type: string
example: d6cf41c2caa14e54a170ba078f5dfe53
marketplace:
description: ID do marketplace
type: string
example: f6cf41c2caa14e54a170ba078f5dfe53
customer:
description: ID do customer
type: string
example: e6cf41c2caa14e54a170ba078f5dfe53
service:
description: Nome do serviço para qual irá criar permissão
type: string
example: "buyers"
resource:
description: recurso do serviço para qual irá criar permissão
type: string
example: "individuals"
action:
type: string
description: Tipo de ações que a permissão irá permitir
example: "GET"
created_at:
type: integer
format: int32
uri:
type: string
example: "/v1/users/d6cf41c2-caa1-4e54-a170-ba078f5dfe53/permissions"
parameters:
userIdParam:
name: user_id
in: path
description: ID user
required: true
type: string
marketplaceParam:
name: marketplace_id
in: path
description: ID marketplace
required: true
type: string
permissionIdParam:
name: permission_id
in: path
description: ID permission
required: true
type: string
limitParam:
name: limit
in: query
description: Limita o número de objetos retornados, podendo ser entre 1 e 100
required: false
type: number
format: int32
default: 20
sortParam:
name: sort
in: query
description: Determinar como ordenar a lista em relação a data de criação do objeto
required: false
type: string
enum:
- time-descending
- time-ascending
default: time-descending
offsetParam:
name: offset
in: query
description: Determina o ponto de inicio dos registros retornados
required: false
type: number
format: int32
default: 0
dateRangeParam:
name: date_range
in: query
description: Filtro na lista base de objetos pela data de criação. O valor pode ser uma string com um horário em UTC timestamp, ou pode ser uma lista com os parametros abaixo
required: false
type: number
dateRangeGTParam:
name: date_range[gt]
in: query
description: Retorna valores onde a data maior que o timestamp informado
required: false
type: number
dateRangeGTEParam:
name: date_range[gte]
in: query
description: Retorna valores onde a data for maior ou igual que o timestamp informado
required: false
type: number
dateRangeLTParam:
name: date_range[lt]
in: query
description: Retorna valores onde a data for menor que o timestamp informado
required: false
type: number
dateRangeLTEParam:
name: date_range[lte]
in: query
description: Retorna valores onde a data for menor ou igual que o timestamp informado
required: false
type: number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment