CampaignFlow.Client (CampaignFlow Client v0.1.0)
View SourceMain client module for the Campaign Flow API.
This module provides a convenient interface for interacting with the Campaign Flow API using OAuth2 authentication and the Req HTTP client library.
Configuration
You can configure the client in your config files:
config :campaign_flow,
base_url: "https://app.campaignflow.com.au/api/v2",
client_id: "your_client_id",
client_secret: "your_client_secret"Or pass configuration directly when creating a client:
client = CampaignFlow.Client.new(
base_url: "https://app.campaignflow.com.au/api/v2",
client_id: "your_client_id",
client_secret: "your_client_secret"
)Usage
# Create a new client
client = CampaignFlow.Client.new(
client_id: "your_client_id",
client_secret: "your_client_secret"
)
# Make API calls using resource modules
{:ok, campaigns} = CampaignFlow.Client.Campaigns.list(client)
{:ok, campaign} = CampaignFlow.Client.Campaigns.get(client, campaign_id)
Summary
Functions
Ensures the client has a valid access token, refreshing if necessary.
Creates a new Campaign Flow API client.
Creates a new client for the test environment.
Checks if the client's current access token is valid.
Types
Functions
Ensures the client has a valid access token, refreshing if necessary.
Examples
client = CampaignFlow.Client.new(client_id: "id", client_secret: "secret")
{:ok, authenticated_client} = CampaignFlow.Client.authenticate(client)
Creates a new Campaign Flow API client.
Options
:base_url- The base URL for the API (overrides environment setting):environment- The environment to use (:prodor:test, defaults to:prod):client_id- OAuth2 client ID (required):client_secret- OAuth2 client secret (required):req_options- Additional options to pass to Req
Examples
client = CampaignFlow.Client.new(client_id: "id", client_secret: "secret")
#=> %CampaignFlow.Client{...}
client = CampaignFlow.Client.new(client_id: "id", client_secret: "secret", environment: :test)
#=> %CampaignFlow.Client{base_url: "https://test.campaignflow.com.au/api/v2", ...}
Creates a new client for the test environment.
Examples
client = CampaignFlow.Client.test(client_id: "id", client_secret: "secret")
#=> %CampaignFlow.Client{base_url: "https://test.campaignflow.com.au/api/v2", ...}
Checks if the client's current access token is valid.