Skip to content

Commit 673db2e

Browse files
author
infobip-ci
committed
Include support for Email API
1 parent a03cfe7 commit 673db2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+7728
-156
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to the library will be documented in this file.
55
The format of the file is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this library adheres to [Semantic Versioning](http://semver.org/) as mentioned in [README.md][readme] file.
77

8+
## [ [2.1.0](https://github.com/infobip/infobip-api-csharp-client/releases/tag/2.1.0) ] - 2021-10-21
9+
10+
### Added
11+
- Support for [Infobip Email API](https://www.infobip.com/docs/api#channels/email)
12+
13+
814
## [ [2.0.0](https://github.com/infobip/infobip-api-csharp-client/releases/tag/2.0.0) ] - 2021-05-11
915

1016
🎉 **NEW Major Version of `Infobip.Api.Client`.**

README.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
[![NuGet](https://badgen.net/nuget/v/Infobip.Api.Client?icon=nuget)](https://www.nuget.org/packages/Infobip.Api.Client)
44
[![MIT License](https://badgen.net/github/license/infobip/infobip-api-csharp-client)](https://opensource.org/licenses/MIT)
55

6-
This is a C# Client for Infobip API and you can use it as a dependency to add [Infobip APIs][apidocs] to your application.
7-
To use this, you'll need an Infobip account. If not already having one, you can create a [free trial][freetrial] account [here][signup].
6+
This is a C# Client for [Infobip API][apidocs] and you can use it as a dependency in your application.
7+
To use this library you'll need an Infobip account. You can create a [free trial][freetrial] account [here][signup].
88

9-
Built on top of [OpenAPI Specification](https://swagger.io/specification/), powered by [OpenAPI Generator](https://openapi-generator.tech/).
9+
The library is built on top of [OpenAPI Specification](https://swagger.io/specification/) and powered by [OpenAPI Generator](https://openapi-generator.tech/).
1010

11-
<img src="https://udesigncss.com/wp-content/uploads/2020/01/Infobip-logo-transparent.png" height="124px" alt="Infobip" />
11+
<img src="https://udesigncss.com/wp-content/uploads/2020/01/Infobip-logo-transparent.png" height="48px" alt="Infobip" />
1212

1313
#### Table of contents:
1414
* [Documentation](#documentation)
@@ -37,25 +37,26 @@ Within Visual Studio, use the Package Manager UI to browse for `Infobip.Api.Clie
3737
#### Package Manager Console
3838
Alternatively, also within Visual Studio, use the Package Manager Console command:
3939

40-
Install-Package Infobip.Api.Client -Version 2.0.0
40+
Install-Package Infobip.Api.Client -Version 2.1.0
4141

4242
#### .NET CLI
4343
If you are used to .NET CLI, the following command is going to be sufficient for you:
4444

45-
dotnet add package Infobip.Api.Client --version 2.0.0
45+
dotnet add package Infobip.Api.Client --version 2.1.0
4646

4747
### Package reference
4848
Including the package directly into project file is also valid option.
4949

50-
<PackageReference Include="Infobip.Api.Client" Version="2.0.0" />
50+
<PackageReference Include="Infobip.Api.Client" Version="2.1.0" />
5151

5252
## Quickstart
5353

5454
#### Initialize the Client
5555

56-
We support multiple authentication methods, e.g. you can use [API Key Header](https://www.infobip.com/docs/essentials/api-authentication#api-key-header). In this case value for `ApiKeyPrefix` in example below will be `App`.
57-
58-
To see your base URL, log in to the [Infobip API Resource][apidocs] hub with your Infobip credentials.
56+
Before initializing client we have to prepare `Configuration` object for handling authentication.
57+
We support multiple authentication methods, e.g. you can use [API Key Header][authentication-apikey].
58+
In this case value for `ApiKeyPrefix` in example below will be `App`.
59+
To see your base URL, log in to the [Infobip API Resource][apidocs] hub with your Infobip account.
5960

6061
```csharp
6162
var configuration = new Configuration()
@@ -64,8 +65,11 @@ To see your base URL, log in to the [Infobip API Resource][apidocs] hub with you
6465
ApiKeyPrefix = "<put API key prefix here (App/Basic/IBSSO/Bearer)>",
6566
ApiKey = "<put your API key here>"
6667
};
67-
68-
var sendSmsApi = new SendSmsApi(configuration);
68+
```
69+
70+
Next step is to initialize the API client. In this case we're instantiating the SMS API client.
71+
```csharp
72+
var sendSmsApi = new SendSmsApi(configuration);
6973
```
7074

7175
Since library is utilizing the `HttpClient` behind the scene for handling the HTTP calls you can provide your own instance of `HttpClient` to `SendSmsApi` constructor and have a control over its lifecycle.
@@ -74,7 +78,7 @@ Since library is utilizing the `HttpClient` behind the scene for handling the HT
7478
```
7579

7680
#### Send an SMS
77-
Simple example for sending an SMS message.
81+
Here's a simple example for sending an SMS message. First prepare the message by creating an instance of `SmsAdvancedTextualRequest` and its nested objects.
7882

7983
```csharp
8084
var smsMessage = new SmsTextualMessage()
@@ -92,8 +96,10 @@ Simple example for sending an SMS message.
9296
Messages = new List<SmsTextualMessage>() { smsMessage }
9397
};
9498
```
95-
Send the message and inspect the `ApiException` for more information in case of failure.
99+
100+
Now we can send the message using client instantiated before and inspect the `ApiException` for more information in case of failure.
96101
You can get the HTTP status code from `ErrorCode` property, and more details about error from `ErrorContent` property.
102+
97103
```csharp
98104
try
99105
{
@@ -136,7 +142,7 @@ Example of webhook implementation:
136142
return Ok();
137143
}
138144
```
139-
If you prefer to use your own serializer, please pay attention to the supported [date format](https://www.infobip.com/docs/essentials/integration-best-practices#date-formats).
145+
If you prefer to use your own serializer, please pay attention to the supported [date format][datetimeformat].
140146
Library is using custom date format string `yyyy-MM-ddTHH:mm:ss.fffzzzz` when serializing dates. This format does not exactly match the format from our documentation above, but it is the closest possible. This format produces the time zone offset value with `:` as time separator, but our backend services will deserialize it correctly.
141147

142148
#### Fetching delivery reports
@@ -154,6 +160,7 @@ Each request will return a batch of delivery reports - only once.
154160

155161
#### Unicode & SMS preview
156162
Infobip API supports Unicode characters and automatically detects encoding. Unicode and non-standard GSM characters use additional space, avoid unpleasant surprises and check how different message configurations will affect your message text, number of characters and message parts.
163+
Use the preview SMS message functionality to verify those details as demonstrated below.
157164

158165
```csharp
159166
var smsPreviewRequest = new SmsPreviewRequest()
@@ -165,8 +172,8 @@ Infobip API supports Unicode characters and automatically detects encoding. Unic
165172
```
166173

167174
#### Receive incoming SMS
168-
If you want to receive SMS messages from your subscribers we can have them delivered to you in real time. When you buy and configure a number capable of receiving SMS, specify your endpoint as explained [here](https://www.infobip.com/docs/api#channels/sms/receive-inbound-sms-messages).
169-
e.g. `https://{yourDomain}/incoming-sms`.
175+
If you want to receive SMS messages from your subscribers we can have them delivered to you in real time.
176+
When you buy and configure a number capable of receiving SMS, specify your endpoint as explained [here][receive-inbound-sms] e.g. `https://{yourDomain}/incoming-sms`.
170177

171178
Example of webhook implementation:
172179

@@ -184,15 +191,22 @@ Example of webhook implementation:
184191
#### Two-Factor Authentication (2FA)
185192
For 2FA quick start guide please check [these examples](two-factor-authentication.md).
186193

194+
#### Send email
195+
For send email quick start guide please check [these examples](email.md).
196+
187197
## Ask for help
188198

189-
Feel free to open issues on the repository for any issue or feature request. As per pull requests, for details check the `CONTRIBUTING` [file][contributing] related to it - in short, we will not merge any pull requests, this code is auto-generated.
199+
Feel free to open issues on the repository for any issue or feature request.
200+
Check the `CONTRIBUTING` [file][contributing] for details about contributions - in short, we will not merge any pull requests since this code is auto-generated.
190201

191-
If it is, however, something that requires our imminent attention feel free to contact us @ [support@infobip.com](mailto:support@infobip.com).
202+
However, if you find something that requires our imminent attention feel free to contact us @ [support@infobip.com](mailto:support@infobip.com).
192203

193204
[apidocs]: https://www.infobip.com/docs/api
194205
[freetrial]: https://www.infobip.com/docs/essentials/free-trial
195206
[signup]: https://www.infobip.com/signup
196207
[semver]: https://semver.org
197208
[license]: LICENSE
198209
[contributing]: CONTRIBUTING.md
210+
[authentication-apikey]: https://www.infobip.com/docs/essentials/api-authentication#api-key-header
211+
[datetimeformat]: https://www.infobip.com/docs/essentials/integration-best-practices#date-formats
212+
[receive-inbound-sms]: https://www.infobip.com/docs/api#channels/sms/receive-inbound-sms-messages

email.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Quickstart
2+
3+
#### Initialize the client with configuration
4+
5+
We support multiple authentication methods, e.g. you can use [API Key Header](https://www.infobip.com/docs/essentials/api-authentication#api-key-header). In this case value for `ApiKeyPrefix` in example below will be `App`.
6+
7+
To see your base URL, log in to the [Infobip API Resource](https://www.infobip.com/docs/api) hub with your Infobip credentials.
8+
9+
```csharp
10+
var configuration = new Configuration()
11+
{
12+
BasePath = "<set your base URL here>",
13+
ApiKeyPrefix = "<set API key prefix here (App/Basic/IBSSO/Bearer)>",
14+
ApiKey = "<set your API key here>"
15+
};
16+
17+
SendEmailApi sendEmailApi = new SendEmailApi(configuration);
18+
```
19+
20+
Before sending email messages you need to verify the domain with which you will be sending emails.
21+
22+
#### Send Email with file attachment
23+
Fields `from`, `to` and `subject` are required, also the message must contain at least one of these: `text`, `html` or `templateId`.
24+
25+
IMPORTANT NOTE:
26+
27+
If you are using Infobip free trial account you can only send messages to registered email.
28+
Also make sure that from parameter is set to YourUserName@selfserviceib.com.
29+
30+
```csharp
31+
try
32+
{
33+
string attachmentFilePath = "/temp/report.csv";
34+
using FileStream attachmentFile = new FileStream(attachmentFilePath, FileMode.Open, FileAccess.Read);
35+
36+
EmailSendResponse sendResponse = sendEmailApi.SendEmail(
37+
"<set your user name>@selfserviceib.com",
38+
"<set your test mail>@<test mail>.com",
39+
"Mail subject text",
40+
text:"Test message with file 2",
41+
attachment:attachmentFile
42+
);
43+
44+
attachmentFile.Dispose();
45+
}
46+
catch (Exception ex)
47+
{
48+
// HANDLE EXCEPTION
49+
}
50+
```
51+
52+
#### Delivery reports
53+
For each message that you send out, we can send you a delivery report in real-time.
54+
All you need to do is specify your endpoint when sending email in `notifyUrl` field.
55+
You can use data models from the library and the pre-configured `com.infobip.JSON` serializer.
56+
57+
Additionally you can use `messageId` or `bulkId` to fetch reports.
58+
```csharp
59+
try
60+
{
61+
string messageId = "<set message>";
62+
string bulkId = "<set bulk id>"
63+
int limit = 10;
64+
ApiReportsResponse apiReportsResponse = sendEmailApi.GetEmailDeliveryReports(messageId, bulkId, limit);
65+
}
66+
catch (Exception ex)
67+
{
68+
// HANDLE EXCEPTION
69+
}
70+
```
71+
72+
Exampe of messageId:
73+
74+
```csharp
75+
messageId = "u3qre3bqdxgom8qhq4ae"
76+
```

0 commit comments

Comments
 (0)