-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_uploads.go
More file actions
152 lines (117 loc) · 5.76 KB
/
Copy pathapi_uploads.go
File metadata and controls
152 lines (117 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
SMS
You can use the SMS endpoints to send and manage SMS, check the cost of sending SMS, view message history, and more. Integrate them into your system as part of your workflow. Relevant guides: <a href=\"https://help.clicksend.com/article/h474eseq3a-how-many-characters-can-i-send-in-an-sms\" target=\"_blank\">How many characters can I send in an SMS?</a>, <a href=\"https://help.clicksend.com/article/1hd33n2xns-sms-status-delivery-receipt-expired\" target=\"_blank\">SMS status delivery receipt expired</a>, <a href=\"https://help.clicksend.com/en/articles/42195-unicode-vs-plain-text\" target=\"_blank\">Do you support non-English characters</a>, and <a href=\"https://help.clicksend.com/category/mfdctha7f0-country-specific-features-and-restrictions\" target=\"_blank\">Country Specific Features and Restrictions</a>. <div class=\"info-box\"> <h4><i class=\"fas fa-info-circle\"></i> Note :</h4> ClickSend is pausing SMS messages containing URLs for new customers. Please remove links from messages to maintain uninterrupted delivery, or <a href=\"https://www.clicksend.com/gb/help/\" target=\"_blank\">contact support</a> to apply for approval for URL messaging. </div>
API version: 1.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package clicksend
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
)
// UploadsAPIService UploadsAPI service
type UploadsAPIService service
type ApiUploadAMediaFileRequest struct {
ctx context.Context
ApiService *UploadsAPIService
contentType *string
body *map[string]interface{}
}
func (r ApiUploadAMediaFileRequest) ContentType(contentType string) ApiUploadAMediaFileRequest {
r.contentType = &contentType
return r
}
func (r ApiUploadAMediaFileRequest) Body(body map[string]interface{}) ApiUploadAMediaFileRequest {
r.body = &body
return r
}
func (r ApiUploadAMediaFileRequest) Execute() (*http.Response, error) {
return r.ApiService.UploadAMediaFileExecute(r)
}
/*
UploadAMediaFile Upload Media File
The `upload` endpoint provides a method for converting files from an unsupported format to a format that one of our endpoints can handle.
Files can be submitted two ways: 1. Using `base64` encoding in an `application/json` request. In this case, submit the `base64`\-encoded file contents in the `content` field of the request body, and `convert` can be specified either also in the body or as part of the query string. 2. Using `multipart/form-data` encoding, in the same way it would be submitted using a HTML form. You may find cURL useful for this. For an example of how to do this, see one of our [SDKs](https://dashboard.clicksend.com/#/libraries-sdk/main). In this case, specify `convert` in the query string.
Note that `convert` specifies the conversion to take place. That is, what the result should be compatible with and can be any of the following:
- `fax`
- `mms`
- `csv`
- `post`
- `postcard`
All files will expire 10 minutes after being uploaded.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| convert | query | string | true | none |
| content | body | string | true | Base64-encoded file contents |
Refer to [Status Codes](/#status-codes) for definitions of HTTP status code responses.
This endpoint requires authentication, [more info...](/#authentication)
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiUploadAMediaFileRequest
*/
func (a *UploadsAPIService) UploadAMediaFile(ctx context.Context) ApiUploadAMediaFileRequest {
return ApiUploadAMediaFileRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *UploadsAPIService) UploadAMediaFileExecute(r ApiUploadAMediaFileRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "UploadsAPIService.UploadAMediaFile")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v3/uploads"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.contentType != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "Content-Type", r.contentType, "simple", "")
}
// body params
localVarPostBody = r.body
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}