# openapi.api.DiscountApi

## Load the API package
```dart
import 'package:openapi/api.dart';
```

All URIs are relative to *http://localhost*

Method | HTTP request | Description
------------- | ------------- | -------------
[**callGet**](DiscountApi.md#callget) | **GET** /api/order/discounts/{id} | Get discount by ID
[**changeStatus**](DiscountApi.md#changestatus) | **PATCH** /api/order/discounts/{id}/status | Update a discount status
[**create**](DiscountApi.md#create) | **POST** /api/order/discounts | Create a new discount
[**createComment**](DiscountApi.md#createcomment) | **POST** /api/order/discounts/{discountId}/comment | Comment on a discount
[**delete**](DiscountApi.md#delete) | **DELETE** /api/order/discounts/{id} | Delete a discount
[**getAll**](DiscountApi.md#getall) | **GET** /api/order/discounts | Get all discounts
[**update**](DiscountApi.md#update) | **PUT** /api/order/discounts/{id} | Update a discount


# **callGet**
> DiscountEntity callGet(id)

Get discount by ID

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final num id = 8.14; // num | ID of discount

try {
    final response = api.callGet(id);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->callGet: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **id** | **num**| ID of discount | 

### Return type

[**DiscountEntity**](DiscountEntity.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **changeStatus**
> DiscountEntity changeStatus(id)

Update a discount status

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final num id = 8.14; // num | ID of discount

try {
    final response = api.changeStatus(id);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->changeStatus: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **id** | **num**| ID of discount | 

### Return type

[**DiscountEntity**](DiscountEntity.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **create**
> DiscountEntity create(discountEntity)

Create a new discount

Creates a new discount, it could be one of the following:  1- Amount off product  2- Amount off order  3- Buy X get Y  4- Free shipping  

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final DiscountEntity discountEntity = {"discountType":"amount_off_product","methodType":"automatic","methodValue":"string","isActive":true,"customerEligibility":"all","limitNumberOfTimesInTotal":0,"limitOneUsePerCustomer":true,"startDate":"2023-05-13","endDate":"2023-05-13","amountOffProduct":{"type":"percentage","value":21,"appliesTo":"products","minimumPurchaseType":"quantity","minimumPurchaseValue":0,"products":[{"id":15}]}}; // DiscountEntity | 

try {
    final response = api.create(discountEntity);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->create: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **discountEntity** | [**DiscountEntity**](DiscountEntity.md)|  | 

### Return type

[**DiscountEntity**](DiscountEntity.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **createComment**
> DiscountCommentEntity createComment(discountId, discountCommentEntity)

Comment on a discount

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final num discountId = 8.14; // num | ID of discount
final DiscountCommentEntity discountCommentEntity = ; // DiscountCommentEntity | 

try {
    final response = api.createComment(discountId, discountCommentEntity);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->createComment: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **discountId** | **num**| ID of discount | 
 **discountCommentEntity** | [**DiscountCommentEntity**](DiscountCommentEntity.md)|  | 

### Return type

[**DiscountCommentEntity**](DiscountCommentEntity.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **delete**
> MessageResponseApiProperty delete(id)

Delete a discount

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final num id = 8.14; // num | ID of discount

try {
    final response = api.delete(id);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->delete: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **id** | **num**| ID of discount | 

### Return type

[**MessageResponseApiProperty**](MessageResponseApiProperty.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **getAll**
> GetAllDiscountsResponse getAll(page, limit, search, sort, status)

Get all discounts

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final num page = 8.14; // num | 
final num limit = 8.14; // num | 
final String search = search_example; // String | 
final GetAllDiscountsBodySort sort = ; // GetAllDiscountsBodySort | 
final DiscountStatuses status = ; // DiscountStatuses | 

try {
    final response = api.getAll(page, limit, search, sort, status);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->getAll: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **page** | **num**|  | [optional] [default to 1]
 **limit** | **num**|  | [optional] [default to 10]
 **search** | **String**|  | [optional] 
 **sort** | [**GetAllDiscountsBodySort**](.md)|  | [optional] 
 **status** | [**DiscountStatuses**](.md)|  | [optional] 

### Return type

[**GetAllDiscountsResponse**](GetAllDiscountsResponse.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **update**
> DiscountEntity update(id, updateDiscountBody)

Update a discount

### Example
```dart
import 'package:openapi/api.dart';

final api = Openapi().getDiscountApi();
final num id = 8.14; // num | ID of discount
final UpdateDiscountBody updateDiscountBody = {"discountType":"amount_off_product","methodType":"automatic","methodValue":"string","isActive":true,"customerEligibility":"all","limitNumberOfTimesInTotal":0,"limitOneUsePerCustomer":true,"startDate":"2023-05-13","endDate":"2023-05-13","amountOffProduct":{"type":"percentage","value":21,"appliesTo":"products","minimumPurchaseType":"quantity","minimumPurchaseValue":0,"products":[{"id":15}]}}; // UpdateDiscountBody | 

try {
    final response = api.update(id, updateDiscountBody);
    print(response);
} catch on DioError (e) {
    print('Exception when calling DiscountApi->update: $e\n');
}
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **id** | **num**| ID of discount | 
 **updateDiscountBody** | [**UpdateDiscountBody**](UpdateDiscountBody.md)|  | 

### Return type

[**DiscountEntity**](DiscountEntity.md)

### Authorization

No authorization required

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

