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
Functions
Callback implementation for Closex.ClientBehaviour.create_lead/2
Callback implementation for Closex.ClientBehaviour.create_opportunity/2
Callback implementation for Closex.ClientBehaviour.find_leads/2
Gets a lead from CloseIO
Gets a lead custom field from CloseIO
Gets the potential statuses of a lead from CloseIO
Gets an opportunity from CloseIO
Gets the potential statuses of an opportunity from CloseIO
Gets an organization from CloseIO
Gets the users available in CloseIO
Callback implementation for Closex.ClientBehaviour.send_email/2
Callback implementation for Closex.ClientBehaviour.update_lead/3
Callback implementation for Closex.ClientBehaviour.update_opportunity/3
Link to this section Functions
Callback implementation for Closex.ClientBehaviour.create_lead/2
.
Callback implementation for Closex.ClientBehaviour.create_opportunity/2
.
Callback implementation for Closex.ClientBehaviour.find_leads/2
.
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())
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())
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…
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())
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…
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())
Gets the users available in CloseIO.
Returns {:ok, users}
.
Examples
> Closex.MockClient.get_users() …contents of test/fixtures/users.json…
Callback implementation for Closex.ClientBehaviour.send_email/2
.
Callback implementation for Closex.ClientBehaviour.update_lead/3
.
Callback implementation for Closex.ClientBehaviour.update_opportunity/3
.