From 72459b3feec623521bae0968f742ef5de05ff3e2 Mon Sep 17 00:00:00 2001 From: aakanksha-sib Date: Mon, 16 Apr 2018 16:30:12 +0530 Subject: [PATCH] Delete contact api added --- README.md | 5 ++ docs/ContactsApi.md | 52 ++++++++++++++++++ docs/GetAccountPlan.md | 9 ++-- lib/sib-api-v3-sdk/api/contacts_api.rb | 54 +++++++++++++++++++ lib/sib-api-v3-sdk/models/get_account_plan.rb | 34 +++++++----- lib/sib-api-v3-sdk/version.rb | 2 +- spec/api/contacts_api_spec.rb | 12 +++++ spec/models/get_account_plan_spec.rb | 10 +++- 8 files changed, 159 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index cfa227a..8b27c88 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Class | Method | HTTP request | Description *SibApiV3Sdk::ContactsApi* | [**create_folder**](docs/ContactsApi.md#create_folder) | **POST** /contacts/folders | Create a folder *SibApiV3Sdk::ContactsApi* | [**create_list**](docs/ContactsApi.md#create_list) | **POST** /contacts/lists | Create a list *SibApiV3Sdk::ContactsApi* | [**delete_attribute**](docs/ContactsApi.md#delete_attribute) | **DELETE** /contacts/attributes/{attributeCategory}/{attributeName} | Deletes an attribute +*SibApiV3Sdk::ContactsApi* | [**delete_contact**](docs/ContactsApi.md#delete_contact) | **DELETE** /contacts/{email} | Deletes a contact *SibApiV3Sdk::ContactsApi* | [**delete_folder**](docs/ContactsApi.md#delete_folder) | **DELETE** /contacts/folders/{folderId} | Delete a folder (and all its lists) *SibApiV3Sdk::ContactsApi* | [**delete_list**](docs/ContactsApi.md#delete_list) | **DELETE** /contacts/lists/{listId} | Delete a list *SibApiV3Sdk::ContactsApi* | [**get_attributes**](docs/ContactsApi.md#get_attributes) | **GET** /contacts/attributes | Lists all attributes @@ -355,3 +356,7 @@ If you find a bug, please post the issue on [Github](https://github.com/sendinbl As always, if you need additional assistance, drop us a note [here](https://account.sendinblue.com/support). +## Recommendation + +Please follow camelCase convention for variables in the API's. For example, use customVariable instead of custom_variable. + diff --git a/docs/ContactsApi.md b/docs/ContactsApi.md index edcb232..fc55624 100644 --- a/docs/ContactsApi.md +++ b/docs/ContactsApi.md @@ -10,6 +10,7 @@ Method | HTTP request | Description [**create_folder**](ContactsApi.md#create_folder) | **POST** /contacts/folders | Create a folder [**create_list**](ContactsApi.md#create_list) | **POST** /contacts/lists | Create a list [**delete_attribute**](ContactsApi.md#delete_attribute) | **DELETE** /contacts/attributes/{attributeCategory}/{attributeName} | Deletes an attribute +[**delete_contact**](ContactsApi.md#delete_contact) | **DELETE** /contacts/{email} | Deletes a contact [**delete_folder**](ContactsApi.md#delete_folder) | **DELETE** /contacts/folders/{folderId} | Delete a folder (and all its lists) [**delete_list**](ContactsApi.md#delete_list) | **DELETE** /contacts/lists/{listId} | Delete a list [**get_attributes**](ContactsApi.md#get_attributes) | **GET** /contacts/attributes | Lists all attributes @@ -353,6 +354,57 @@ nil (empty response body) +# **delete_contact** +> delete_contact(email) + +Deletes a contact + +### Example +```ruby +# load the gem +require 'sib-api-v3-sdk' +# setup authorization +SibApiV3Sdk.configure do |config| + # Configure API key authorization: api-key + config.api_key['api-key'] = 'YOUR API KEY' + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + #config.api_key_prefix['api-key'] = 'Bearer' +end + +api_instance = SibApiV3Sdk::ContactsApi.new + +email = "email_example" # String | Email (urlencoded) of the contact + + +begin + #Deletes a contact + api_instance.delete_contact(email) +rescue SibApiV3Sdk::ApiError => e + puts "Exception when calling ContactsApi->delete_contact: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **email** | **String**| Email (urlencoded) of the contact | + +### Return type + +nil (empty response body) + +### Authorization + +[api-key](../README.md#api-key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + + # **delete_folder** > delete_folder(folder_id) diff --git a/docs/GetAccountPlan.md b/docs/GetAccountPlan.md index af8f221..a2cb418 100644 --- a/docs/GetAccountPlan.md +++ b/docs/GetAccountPlan.md @@ -4,9 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **type** | **String** | Displays the plan type of the user | -**credits_type** | **String** | This is the type of the credit, \"User Limit\" or \"Send Limit\" are two possible types of credit of a user. \"User Limit\" implies the total number of subscribers you can add to your account, and \"Send Limit\" implies the total number of emails you can send to the subscribers in your account. | -**credits** | **Float** | Remaining credits of the user. This can either be \"User Limit\" or \"Send Limit\" depending on the plan. | -**start_date** | **Date** | Date of the period from which the plan will start (only available for \"subscription\", \"unlimited\" and \"reseller\" plan type) | [optional] -**end_date** | **Date** | Date of the period from which the plan will end (only available for \"subscription\", \"unlimited\" and \"reseller\" plan type) | [optional] +**credits_type** | **String** | This is the type of the credit, \"Send Limit\" is one of the possible types of credit of a user. \"Send Limit\" implies the total number of emails you can send to the subscribers in your account. | +**credits** | **Float** | Remaining credits of the user | +**start_date** | **Date** | Date of the period from which the plan will start (only available for \"subscription\" and \"reseller\" plan type) | [optional] +**end_date** | **Date** | Date of the period from which the plan will end (only available for \"subscription\" and \"reseller\" plan type) | [optional] +**user_limit** | **Integer** | Only in case of reseller account. It implies the total number of child accounts you can add to your account. | [optional] diff --git a/lib/sib-api-v3-sdk/api/contacts_api.rb b/lib/sib-api-v3-sdk/api/contacts_api.rb index d9b8582..18c88f2 100644 --- a/lib/sib-api-v3-sdk/api/contacts_api.rb +++ b/lib/sib-api-v3-sdk/api/contacts_api.rb @@ -380,6 +380,60 @@ def delete_attribute_with_http_info(attribute_category, attribute_name, opts = { return data, status_code, headers end + # Deletes a contact + # + # @param email Email (urlencoded) of the contact + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_contact(email, opts = {}) + delete_contact_with_http_info(email, opts) + return nil + end + + # Deletes a contact + # + # @param email Email (urlencoded) of the contact + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_contact_with_http_info(email, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: ContactsApi.delete_contact ..." + end + # verify the required parameter 'email' is set + if @api_client.config.client_side_validation && email.nil? + fail ArgumentError, "Missing the required parameter 'email' when calling ContactsApi.delete_contact" + end + # resource path + local_var_path = "/contacts/{email}".sub('{' + 'email' + '}', email.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = ['api-key'] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ContactsApi#delete_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete a folder (and all its lists) # # @param folder_id Id of the folder diff --git a/lib/sib-api-v3-sdk/models/get_account_plan.rb b/lib/sib-api-v3-sdk/models/get_account_plan.rb index d5b457a..1ed4ff0 100644 --- a/lib/sib-api-v3-sdk/models/get_account_plan.rb +++ b/lib/sib-api-v3-sdk/models/get_account_plan.rb @@ -18,18 +18,21 @@ class GetAccountPlan # Displays the plan type of the user attr_accessor :type - # This is the type of the credit, \"User Limit\" or \"Send Limit\" are two possible types of credit of a user. \"User Limit\" implies the total number of subscribers you can add to your account, and \"Send Limit\" implies the total number of emails you can send to the subscribers in your account. + # This is the type of the credit, \"Send Limit\" is one of the possible types of credit of a user. \"Send Limit\" implies the total number of emails you can send to the subscribers in your account. attr_accessor :credits_type - # Remaining credits of the user. This can either be \"User Limit\" or \"Send Limit\" depending on the plan. + # Remaining credits of the user attr_accessor :credits - # Date of the period from which the plan will start (only available for \"subscription\", \"unlimited\" and \"reseller\" plan type) + # Date of the period from which the plan will start (only available for \"subscription\" and \"reseller\" plan type) attr_accessor :start_date - # Date of the period from which the plan will end (only available for \"subscription\", \"unlimited\" and \"reseller\" plan type) + # Date of the period from which the plan will end (only available for \"subscription\" and \"reseller\" plan type) attr_accessor :end_date + # Only in case of reseller account. It implies the total number of child accounts you can add to your account. + attr_accessor :user_limit + class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values @@ -59,7 +62,8 @@ def self.attribute_map :'credits_type' => :'creditsType', :'credits' => :'credits', :'start_date' => :'startDate', - :'end_date' => :'endDate' + :'end_date' => :'endDate', + :'user_limit' => :'userLimit' } end @@ -70,7 +74,8 @@ def self.swagger_types :'credits_type' => :'String', :'credits' => :'Float', :'start_date' => :'Date', - :'end_date' => :'Date' + :'end_date' => :'Date', + :'user_limit' => :'Integer' } end @@ -102,6 +107,10 @@ def initialize(attributes = {}) self.end_date = attributes[:'endDate'] end + if attributes.has_key?(:'userLimit') + self.user_limit = attributes[:'userLimit'] + end + end # Show invalid properties with the reasons. Usually used together with valid? @@ -127,10 +136,10 @@ def list_invalid_properties # @return true if the model is valid def valid? return false if @type.nil? - type_validator = EnumAttributeValidator.new('String', ["payAsYouGo", "unlimited", "free", "subscription", "sms", "reseller"]) + type_validator = EnumAttributeValidator.new('String', ["payAsYouGo", "free", "subscription", "sms", "reseller"]) return false unless type_validator.valid?(@type) return false if @credits_type.nil? - credits_type_validator = EnumAttributeValidator.new('String', ["userLimit", "sendLimit"]) + credits_type_validator = EnumAttributeValidator.new('String', ["sendLimit"]) return false unless credits_type_validator.valid?(@credits_type) return false if @credits.nil? return true @@ -139,7 +148,7 @@ def valid? # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) - validator = EnumAttributeValidator.new('String', ["payAsYouGo", "unlimited", "free", "subscription", "sms", "reseller"]) + validator = EnumAttributeValidator.new('String', ["payAsYouGo", "free", "subscription", "sms", "reseller"]) unless validator.valid?(type) fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}." end @@ -149,7 +158,7 @@ def type=(type) # Custom attribute writer method checking allowed values (enum). # @param [Object] credits_type Object to be assigned def credits_type=(credits_type) - validator = EnumAttributeValidator.new('String', ["userLimit", "sendLimit"]) + validator = EnumAttributeValidator.new('String', ["sendLimit"]) unless validator.valid?(credits_type) fail ArgumentError, "invalid value for 'credits_type', must be one of #{validator.allowable_values}." end @@ -165,7 +174,8 @@ def ==(o) credits_type == o.credits_type && credits == o.credits && start_date == o.start_date && - end_date == o.end_date + end_date == o.end_date && + user_limit == o.user_limit end # @see the `==` method @@ -177,7 +187,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [type, credits_type, credits, start_date, end_date].hash + [type, credits_type, credits, start_date, end_date, user_limit].hash end # Builds the object from hash diff --git a/lib/sib-api-v3-sdk/version.rb b/lib/sib-api-v3-sdk/version.rb index 0484c70..6011a18 100644 --- a/lib/sib-api-v3-sdk/version.rb +++ b/lib/sib-api-v3-sdk/version.rb @@ -11,5 +11,5 @@ =end module SibApiV3Sdk - VERSION = "4.0.0" + VERSION = "4.0.1" end diff --git a/spec/api/contacts_api_spec.rb b/spec/api/contacts_api_spec.rb index a322d0d..e330a64 100644 --- a/spec/api/contacts_api_spec.rb +++ b/spec/api/contacts_api_spec.rb @@ -108,6 +108,18 @@ end end + # unit tests for delete_contact + # Deletes a contact + # + # @param email Email (urlencoded) of the contact + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'delete_contact test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + # unit tests for delete_folder # Delete a folder (and all its lists) # diff --git a/spec/models/get_account_plan_spec.rb b/spec/models/get_account_plan_spec.rb index 6407e6c..d2faf00 100644 --- a/spec/models/get_account_plan_spec.rb +++ b/spec/models/get_account_plan_spec.rb @@ -35,7 +35,7 @@ describe 'test attribute "type"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - #validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["payAsYouGo", "unlimited", "free", "subscription", "sms", "reseller"]) + #validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["payAsYouGo", "free", "subscription", "sms", "reseller"]) #validator.allowable_values.each do |value| # expect { @instance.type = value }.not_to raise_error #end @@ -45,7 +45,7 @@ describe 'test attribute "credits_type"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - #validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["userLimit", "sendLimit"]) + #validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["sendLimit"]) #validator.allowable_values.each do |value| # expect { @instance.credits_type = value }.not_to raise_error #end @@ -70,5 +70,11 @@ end end + describe 'test attribute "user_limit"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + end