CampaignFlow.Client (CampaignFlow Client v2.0.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
Types
Functions
Creates a new Campaign Flow API client.
The client credentials are configured via Application config, not passed directly. Tokens are managed by a TokenManager process for the specified environment.
Options
:environment- The environment to use (:prod,:test, or custom atom) (required):base_url- The base URL for the API (optional, overrides environment default):req_options- Additional options to pass to Req
Examples
client = CampaignFlow.Client.new(environment: :prod)
#=> %CampaignFlow.Client{environment: :prod, ...}
client = CampaignFlow.Client.new(environment: :test)
#=> %CampaignFlow.Client{environment: :test, base_url: "https://test.campaignflow.com.au/api/v2", ...}
client = CampaignFlow.Client.new(environment: :prod, base_url: "https://custom.example.com/api/v2")
#=> %CampaignFlow.Client{environment: :prod, base_url: "https://custom.example.com/api/v2", ...}
Creates a new client for the test environment.
Convenience function that sets environment to :test.
Examples
client = CampaignFlow.Client.test()
#=> %CampaignFlow.Client{environment: :test, base_url: "https://test.campaignflow.com.au/api/v2", ...}