1
0
mirror of synced 2025-12-25 02:09:19 -05:00

source-brex contribution from natikgadzhi (#48017)

This commit is contained in:
Natik Gadzhi
2024-11-06 13:36:38 -08:00
committed by GitHub
parent e6d3cde64a
commit 5157ad3a00
6 changed files with 537 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
# Brex
This directory contains the manifest-only connector for `source-brex`.
Fetches data on users, expenses, transactions, vendors, and budgets from Brex API.
## Usage
There are multiple ways to use this connector:
- You can use this connector as any other connector in Airbyte Marketplace.
- You can load this connector in `pyairbyte` using `get_source`!
- You can open this connector in Connector Builder, edit it, and publish to your workspaces.
Please refer to the manifest-only connector documentation for more details.
## Local Development
We recommend you use the Connector Builder to edit this connector.
But, if you want to develop this connector locally, you can use the following steps.
### Environment Setup
You will need `airbyte-ci` installed. You can find the documentation [here](airbyte-ci).
### Build
This will create a dev image (`source-brex:dev`) that you can use to test the connector locally.
```bash
airbyte-ci connectors --name=source-brex build
```
### Test
This will run the acceptance tests for the connector.
```bash
airbyte-ci connectors --name=source-brex test
```

View File

@@ -0,0 +1,17 @@
# See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-brex:dev
acceptance_tests:
spec:
tests:
- spec_path: "manifest.yaml"
connection:
bypass_reason: "This is a builder contribution, and we do not have secrets at this time"
discovery:
bypass_reason: "This is a builder contribution, and we do not have secrets at this time"
basic_read:
bypass_reason: "This is a builder contribution, and we do not have secrets at this time"
incremental:
bypass_reason: "This is a builder contribution, and we do not have secrets at this time"
full_refresh:
bypass_reason: "This is a builder contribution, and we do not have secrets at this time"

View File

@@ -0,0 +1,3 @@
<svg width="250" height="250" viewBox="0 0 250 250" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M149.016 71.2065C142.779 79.5495 141.321 82.3035 135.327 82.3035H45.6602V188.899H80.8142C88.7522 188.899 96.4472 185.092 101.388 178.693C107.787 170.188 108.678 167.597 114.915 167.597H204.744V61.0005H169.347C161.409 61.0005 153.714 64.8075 149.016 71.2065ZM176.88 140.056H139.377C131.196 140.056 123.744 143.458 118.803 150.1C112.404 158.605 111.108 161.197 105.114 161.197H73.2812V110.086H110.784C118.965 110.086 126.417 106.279 131.358 99.8805C137.757 91.5375 139.539 89.0265 145.29 89.0265H176.799V140.056H176.88Z" fill="#212121"/>
</svg>

After

Width:  |  Height:  |  Size: 652 B

View File

@@ -0,0 +1,419 @@
version: 5.15.0
type: DeclarativeSource
description: >-
Fetches data on users, expenses, transactions, vendors, and budgets from Brex
API.
check:
type: CheckStream
stream_names:
- transactions
definitions:
streams:
transactions:
type: DeclarativeStream
name: transactions
primary_key:
- id
retriever:
type: SimpleRetriever
requester:
$ref: "#/definitions/base_requester"
path: /v2/transactions/card/primary
http_method: GET
record_selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path:
- items
paginator:
type: DefaultPaginator
page_token_option:
type: RequestOption
inject_into: request_parameter
field_name: cursor
pagination_strategy:
type: CursorPagination
cursor_value: "{{ response.get('next_cursor') }}"
stop_condition: "{{ response.get('next_cursor') is none }}"
incremental_sync:
type: DatetimeBasedCursor
cursor_field: posted_at_date
lookback_window: P1D
cursor_datetime_formats:
- "%Y-%m-%d"
datetime_format: "%Y-%m-%dT%H:%M:%S"
start_datetime:
type: MinMaxDatetime
datetime: "{{ config[\"start_date\"] }}"
datetime_format: "%Y-%m-%dT%H:%M:%SZ"
start_time_option:
type: RequestOption
inject_into: request_parameter
field_name: posted_at_start
schema_loader:
type: InlineSchemaLoader
schema:
$ref: "#/schemas/transactions"
users:
type: DeclarativeStream
name: users
primary_key:
- id
retriever:
type: SimpleRetriever
requester:
$ref: "#/definitions/base_requester"
path: /v2/users
http_method: GET
record_selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path:
- items
paginator:
type: DefaultPaginator
page_token_option:
type: RequestOption
inject_into: request_parameter
field_name: cursor
pagination_strategy:
type: CursorPagination
cursor_value: "{{ response.get('next_cursor') }}"
stop_condition: "{{ response.get('next_cursor') is none }}"
schema_loader:
type: InlineSchemaLoader
schema:
$ref: "#/schemas/users"
departments:
type: DeclarativeStream
name: departments
primary_key:
- id
retriever:
type: SimpleRetriever
requester:
$ref: "#/definitions/base_requester"
path: /v2/departments
http_method: GET
record_selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path:
- items
paginator:
type: DefaultPaginator
page_token_option:
type: RequestOption
inject_into: request_parameter
field_name: cursor
pagination_strategy:
type: CursorPagination
cursor_value: "{{ response.get('next_cursor') }}"
stop_condition: "{{ response.get('next_cursor') is none }}"
schema_loader:
type: InlineSchemaLoader
schema:
$ref: "#/schemas/departments"
vendors:
type: DeclarativeStream
name: vendors
primary_key:
- id
retriever:
type: SimpleRetriever
requester:
$ref: "#/definitions/base_requester"
path: /v1/vendors
http_method: GET
record_selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path:
- items
paginator:
type: DefaultPaginator
page_token_option:
type: RequestOption
inject_into: request_parameter
field_name: cursor
pagination_strategy:
type: CursorPagination
cursor_value: "{{ response.get('next_cursor') }}"
stop_condition: "{{ response.get('next_cursor') is none }}"
schema_loader:
type: InlineSchemaLoader
schema:
$ref: "#/schemas/vendors"
expenses:
type: DeclarativeStream
name: expenses
primary_key:
- id
retriever:
type: SimpleRetriever
requester:
$ref: "#/definitions/base_requester"
path: /v1/expenses/card
http_method: GET
record_selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path:
- items
paginator:
type: DefaultPaginator
page_token_option:
type: RequestOption
inject_into: request_parameter
field_name: cursor
pagination_strategy:
type: CursorPagination
cursor_value: "{{ response.get('next_cursor') }}"
stop_condition: "{{ response.get('next_cursor') is none }}"
incremental_sync:
type: DatetimeBasedCursor
cursor_field: purchased_at
lookback_window: P1M
cursor_datetime_formats:
- "%Y-%m-%dT%H:%M:%SZ"
- "%Y-%m-%dT%H:%M:%S.%fZ"
datetime_format: "%Y-%m-%dT%H:%M:%S"
start_datetime:
type: MinMaxDatetime
datetime: "{{ config[\"start_date\"] }}"
datetime_format: "%Y-%m-%dT%H:%M:%SZ"
start_time_option:
type: RequestOption
inject_into: request_parameter
field_name: purchased_at_start
end_time_option:
type: RequestOption
inject_into: request_parameter
field_name: purchased_at_end
end_datetime:
type: MinMaxDatetime
datetime: "{{ now_utc().strftime('%Y-%m-%dT%H:%M:%SZ') }}"
datetime_format: "%Y-%m-%dT%H:%M:%SZ"
schema_loader:
type: InlineSchemaLoader
schema:
$ref: "#/schemas/expenses"
budgets:
type: DeclarativeStream
name: budgets
primary_key:
- budget_id
retriever:
type: SimpleRetriever
requester:
$ref: "#/definitions/base_requester"
path: /v2/budgets
http_method: GET
record_selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path:
- items
paginator:
type: DefaultPaginator
page_token_option:
type: RequestOption
inject_into: request_parameter
field_name: cursor
pagination_strategy:
type: CursorPagination
cursor_value: "{{ response.get('next_cursor') }}"
stop_condition: "{{ response.get('next_cursor') is none }}"
schema_loader:
type: InlineSchemaLoader
schema:
$ref: "#/schemas/budgets"
base_requester:
type: HttpRequester
url_base: https://platform.brexapis.com
authenticator:
type: BearerAuthenticator
api_token: "{{ config[\"user_token\"] }}"
streams:
- $ref: "#/definitions/streams/transactions"
- $ref: "#/definitions/streams/users"
- $ref: "#/definitions/streams/departments"
- $ref: "#/definitions/streams/vendors"
- $ref: "#/definitions/streams/expenses"
- $ref: "#/definitions/streams/budgets"
spec:
type: Spec
connection_specification:
type: object
$schema: http://json-schema.org/draft-07/schema#
required:
- user_token
- start_date
properties:
user_token:
type: string
description: >-
User token to authenticate API requests. Generate it from your Brex
dashboard under Developer > Settings.
name: user_token
title: User Token
airbyte_secret: true
order: 0
start_date:
type: string
title: Start date
format: date-time
pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$
order: 1
additionalProperties: true
metadata:
autoImportSchema:
transactions: true
users: false
departments: false
vendors: false
expenses: false
budgets: false
testedStreams:
transactions:
streamHash: 9095688de0c91a5eafb2969f27859182d0eb1329
hasResponse: true
responsesAreSuccessful: true
hasRecords: true
primaryKeysArePresent: true
primaryKeysAreUnique: true
users:
streamHash: 22fb9114f7bec24f5b753c0eed981138105cd5e6
hasResponse: true
responsesAreSuccessful: true
hasRecords: true
primaryKeysArePresent: true
primaryKeysAreUnique: true
departments:
streamHash: 3a7de8adfde28e720a9f9254c63103d34bfc3966
hasResponse: true
responsesAreSuccessful: true
hasRecords: true
primaryKeysArePresent: true
primaryKeysAreUnique: true
vendors:
streamHash: 678154fbac1bda4601d2a9ce17e8e4283df96e22
hasResponse: true
responsesAreSuccessful: true
hasRecords: true
primaryKeysArePresent: true
primaryKeysAreUnique: true
expenses:
streamHash: 83d3aa00696a8b74df332824a39fbcf75bdebd7d
hasResponse: true
responsesAreSuccessful: true
hasRecords: true
primaryKeysArePresent: true
primaryKeysAreUnique: true
budgets:
streamHash: 9bfb438f0d1d68b61814339b4153e4904088baaa
hasResponse: true
responsesAreSuccessful: true
hasRecords: true
primaryKeysArePresent: true
primaryKeysAreUnique: true
assist:
docsUrl: https://developer.brex.com/openapi/transactions_api/
schemas:
transactions:
type: object
$schema: http://json-schema.org/schema#
additionalProperties: true
properties:
type:
type:
- string
- "null"
description:
type:
- string
- "null"
amount:
type:
- object
- "null"
properties:
amount:
type:
- number
- "null"
currency:
type:
- string
- "null"
card_id:
type:
- string
- "null"
id:
type: string
initiated_at_date:
type:
- string
- "null"
merchant:
type:
- object
- "null"
properties:
country:
type:
- string
- "null"
mcc:
type:
- string
- "null"
raw_descriptor:
type:
- string
- "null"
posted_at_date:
type: string
required:
- id
- posted_at_date
users:
type: object
$schema: http://json-schema.org/draft-07/schema#
additionalProperties: true
properties: {}
departments:
type: object
$schema: http://json-schema.org/draft-07/schema#
additionalProperties: true
properties: {}
vendors:
type: object
$schema: http://json-schema.org/draft-07/schema#
additionalProperties: true
properties: {}
expenses:
type: object
$schema: http://json-schema.org/draft-07/schema#
additionalProperties: true
properties: {}
budgets:
type: object
$schema: http://json-schema.org/draft-07/schema#
additionalProperties: true
properties: {}

View File

@@ -0,0 +1,35 @@
metadataSpecVersion: "1.0"
data:
allowedHosts:
hosts:
- "platform.brexapis.com"
registryOverrides:
oss:
enabled: true
cloud:
enabled: true
remoteRegistries:
pypi:
enabled: false
packageName: airbyte-source-brex
connectorBuildOptions:
baseImage: docker.io/airbyte/source-declarative-manifest:5.17.0@sha256:9c6bfd080a247b7781ce5b25687e7c44e29d31315d0bf656584b38810521bbaa
connectorSubtype: api
connectorType: source
definitionId: 7d605ca7-f2b8-41c4-96a7-3d5637e58d6d
dockerImageTag: 0.0.1
dockerRepository: airbyte/source-brex
githubIssueLabel: source-brex
icon: icon.svg
license: MIT
name: Brex
releaseDate: 2024-10-30
releaseStage: alpha
supportLevel: community
documentationUrl: https://docs.airbyte.com/integrations/sources/brex
tags:
- language:manifest-only
- cdk:low-code
ab_internal:
ql: 100
sl: 100

View File

@@ -0,0 +1,30 @@
# Brex
Fetches data on users, expenses, transactions, vendors, and budgets from Brex API.
## Configuration
| Input | Type | Description | Default Value |
|-------|------|-------------|---------------|
| `user_token` | `string` | User Token. User token to authenticate API requests. Generate it from your Brex dashboard under Developer &gt; Settings. | |
| `start_date` | `string` | Start date. | |
## Streams
| Stream Name | Primary Key | Pagination | Supports Full Sync | Supports Incremental |
|-------------|-------------|------------|---------------------|----------------------|
| transactions | id | DefaultPaginator | ✅ | ✅ |
| users | id | DefaultPaginator | ✅ | ❌ |
| departments | id | DefaultPaginator | ✅ | ❌ |
| vendors | id | DefaultPaginator | ✅ | ❌ |
| expenses | id | DefaultPaginator | ✅ | ✅ |
| budgets | budget_id | DefaultPaginator | ✅ | ❌ |
## Changelog
<details>
<summary>Expand to review</summary>
| Version | Date | Pull Request | Subject |
|------------------|-------------------|--------------|----------------|
| 0.0.1 | 2024-10-30 | | Initial release by [@natikgadzhi](https://github.com/natikgadzhi) via Connector Builder |
</details>