closex v0.5.4 Closex.MockClient

This module is for testing, it allows you to stub requests to CloseIO.

It behaves like the standard client so you can drop it into your code via configuration in your testing environment, but it will return the test objects for each method.

It gets these test objects from json files, for more detail see the test/fixtures/*.json files.

However, you can override the response of the mock client with json more specific to your domain:

# your_app/config/test.exs

config :yourapp,
  closeio_client: Closex.MockClient,
  ...other configuration...

config :closex,
  mock_client_fixtures_dir: Path.join([File.cwd!, "path", "to", "your", "fixtures"])

If you’d like to emulate not finding an object, pass in the Closex.MockClient.not_found_id value.

For specific examples please see the documentation for the method you’re using.

Link to this section Summary

Link to this section Functions

Link to this function create_lead(payload, opts \\ [])

Callback implementation for Closex.ClientBehaviour.create_lead/2.

Link to this function create_opportunity(payload, opts \\ [])

Callback implementation for Closex.ClientBehaviour.create_opportunity/2.

Link to this function find_leads(search_term, opts \\ [])

Callback implementation for Closex.ClientBehaviour.find_leads/2.

Link to this function get_lead(id, opts \\ [])

Gets a lead from CloseIO.

Returns {:ok, lead}.

Examples

> Closex.MockClient.get_lead(Closex.MockClient.lead_id()) …contents of test/fixtures/lead.json…

iex> Closex.MockClient.get_lead(Closex.MockClient.not_found_id())

Link to this function get_lead_custom_field(id, opts \\ [])

Gets a lead custom field from CloseIO.

Returns {:ok, lead_custom_field}.

Examples

> Closex.MockClient.get_lead_custom_field(Closex.MockClient.lead_custom_field_id()) …contents of test/fixtures/lead_custom_field.json…

iex> Closex.MockClient.get_lead_custom_field(Closex.MockClient.not_found_id())

Link to this function get_lead_statuses(opts \\ [])

Gets the potential statuses of a lead from CloseIO.

Returns {:ok, lead_statuses}.

Examples

> Closex.MockClient.get_lead_statuses() …contents of test/fixtures/lead_statuses.json…

Link to this function get_opportunity(id, opts \\ [])

Gets an opportunity from CloseIO.

Returns {:ok, opportunity}.

Examples

> Closex.MockClient.get_opportunity(Closex.MockClient.opportunity_id()) …contents of test/fixtures/opportunity.json…

iex> Closex.MockClient.get_opportunity(Closex.MockClient.not_found_id())

Link to this function get_opportunity_statuses(opts \\ [])

Gets the potential statuses of an opportunity from CloseIO.

Returns {:ok, opportunity_statuses}.

Examples

> Closex.MockClient.get_opportunity_statuses() …contents of test/fixtures/opportunity_statuses.json…

Link to this function get_organization(id, opts \\ [])

Gets an organization from CloseIO.

Returns {:ok, organization}.

Examples

> Closex.MockClient.get_organization(Closex.MockClient.organization_id()) …contents of test/fixtures/organization.json…

iex> Closex.MockClient.get_organization(Closex.MockClient.not_found_id())

Link to this function get_users(opts \\ [])

Gets the users available in CloseIO.

Returns {:ok, users}.

Examples

> Closex.MockClient.get_users() …contents of test/fixtures/users.json…

Link to this function lead_custom_field_id()
Link to this function opportunity_id()
Link to this function organization_id()
Link to this function send_email(payload, opts \\ [])

Callback implementation for Closex.ClientBehaviour.send_email/2.

Link to this function update_lead(lead_id, payload, opts \\ [])

Callback implementation for Closex.ClientBehaviour.update_lead/3.

Link to this function update_opportunity(opportunity_id, payload, opts \\ [])

Callback implementation for Closex.ClientBehaviour.update_opportunity/3.