|
| 1 | +# Moments quickstart |
| 2 | + |
| 3 | +This quick guide aims to help you start with [Infobip Moments API](https://www.infobip.com/docs/api/customer-engagement/moments). After reading it, you should know how to use Moments. |
| 4 | + |
| 5 | +The first step is to create an `ApiClient` instance with some configuration. |
| 6 | + |
| 7 | +```python |
| 8 | +from infobip_api_client.api_client import ApiClient, Configuration |
| 9 | + |
| 10 | +client_config = Configuration( |
| 11 | + host="<YOUR_BASE_URL>", |
| 12 | + api_key={"APIKeyHeader": "<YOUR_API_KEY>"}, |
| 13 | + api_key_prefix={"APIKeyHeader": "<YOUR_API_PREFIX>"}, |
| 14 | +) |
| 15 | + |
| 16 | +api_client = ApiClient(client_config) |
| 17 | +``` |
| 18 | + |
| 19 | +## Flow API |
| 20 | + |
| 21 | +You can now create an instance of `FlowApi` which allows you to manage your flows. |
| 22 | + |
| 23 | +````python |
| 24 | +from infobip_api_client.api import FlowApi |
| 25 | + |
| 26 | +api_instance = FlowApi(api_client) |
| 27 | +```` |
| 28 | +### Add participants to flow |
| 29 | + |
| 30 | +To add participants to a flow, you can use the following code: |
| 31 | + |
| 32 | +````python |
| 33 | +from infobip_api_client import ( |
| 34 | + FlowAddFlowParticipantsRequest, |
| 35 | + FlowParticipant, |
| 36 | + FlowPersonUniqueField, |
| 37 | + FlowPersonUniqueFieldType, |
| 38 | +) |
| 39 | + |
| 40 | +campaign_id = 200000000000001 |
| 41 | + |
| 42 | +request = FlowAddFlowParticipantsRequest( |
| 43 | + participants=[ |
| 44 | + FlowParticipant( |
| 45 | + identify_by=FlowPersonUniqueField( |
| 46 | + identifier="[email protected]", type=FlowPersonUniqueFieldType. EMAIL |
| 47 | + ), |
| 48 | + variables={"orderNumber": 1167873391}, |
| 49 | + ), |
| 50 | + ], |
| 51 | + notify_url="https://example.com" |
| 52 | + ) |
| 53 | + |
| 54 | +api_response = api_instance.add_flow_participants(campaign_id, request) |
| 55 | +```` |
| 56 | + |
| 57 | +### Get a report on participants added to flow |
| 58 | + |
| 59 | +To fetch a report to confirm that all persons have been successfully added to the flow, you can use the following code: |
| 60 | + |
| 61 | +````python |
| 62 | +given_operation_id = "03f2d474-0508-46bf-9f3d-d8e2c28adaea" |
| 63 | + |
| 64 | +api_response = api_instance.get_flow_participants_added_report(campaign_id, given_operation_id) |
| 65 | +```` |
| 66 | + |
| 67 | +### Remove person from flow |
| 68 | + |
| 69 | +To remove a person from a flow, you can use the following code: |
| 70 | + |
| 71 | +````python |
| 72 | +external_id = "8edb24b5-0319-48cd-a1d9-1e8bc5d577ab" |
| 73 | + |
| 74 | +api_response = api_instance.remove_people_from_flow(campaign_id=campaign_id, external_id=external_id) |
| 75 | +```` |
| 76 | + |
| 77 | + |
| 78 | +## Forms API |
| 79 | + |
| 80 | +You can now create an instance of `FormsApi` which allows you to manage your forms. |
| 81 | + |
| 82 | +````python |
| 83 | +from infobip_api_client.api import FormsApi |
| 84 | + |
| 85 | +api_instance = FormsApi(api_client) |
| 86 | +```` |
| 87 | + |
| 88 | +### Get forms |
| 89 | + |
| 90 | +To get all forms, you can use the following code: |
| 91 | + |
| 92 | +````python |
| 93 | +api_response = api_instance.get_forms() |
| 94 | +```` |
| 95 | + |
| 96 | +### Get form by ID |
| 97 | + |
| 98 | +To get a specific form by ID, you can use the following code: |
| 99 | + |
| 100 | +````python |
| 101 | +form_id = "cec5dfd2-4238-48e0-933b-9acbdb2e6f5f" |
| 102 | + |
| 103 | +api_response = api_instance.get_form(form_id) |
| 104 | +```` |
| 105 | + |
| 106 | +### Increment form view count |
| 107 | + |
| 108 | +To increase the view counter of a specific form, you can use the following code: |
| 109 | + |
| 110 | +````python |
| 111 | +api_response = api_instance.increment_view_count(form_id) |
| 112 | +```` |
| 113 | + |
| 114 | +### Submit form data |
| 115 | + |
| 116 | +To submit data to a specific form, you can use the following code: |
| 117 | + |
| 118 | +````python |
| 119 | +form_data_request = { |
| 120 | + "first_name": "John", |
| 121 | + "last_name": "Doe", |
| 122 | + "company": "Infobip", |
| 123 | + |
| 124 | +} |
| 125 | +api_response = api_instance.submit_form_data(form_id, form_data_request) |
| 126 | +```` |
0 commit comments