cdek_api_client 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,8 @@
2
2
 
3
3
  module CDEKApiClient
4
4
  module Entities
5
+ # Represents a location in the CDEK API.
6
+ # Each location has attributes such as code, city, and address.
5
7
  class Location
6
8
  include Validatable
7
9
 
@@ -11,6 +13,12 @@ module CDEKApiClient
11
13
  validates :city, type: :string
12
14
  validates :address, type: :string
13
15
 
16
+ # Initializes a new Location object.
17
+ #
18
+ # @param code [Integer] the code of the location.
19
+ # @param city [String, nil] the city of the location.
20
+ # @param address [String, nil] the address of the location.
21
+ # @raise [ArgumentError] if any attribute validation fails.
14
22
  def initialize(code:, city: nil, address: nil)
15
23
  @code = code
16
24
  @city = city
@@ -18,6 +26,9 @@ module CDEKApiClient
18
26
  validate!
19
27
  end
20
28
 
29
+ # Converts the Location object to a JSON representation.
30
+ #
31
+ # @return [String] the JSON representation of the Location.
21
32
  def to_json(*_args)
22
33
  {
23
34
  code: @code,
@@ -7,6 +7,8 @@ require_relative 'sender'
7
7
 
8
8
  module CDEKApiClient
9
9
  module Entities
10
+ # Represents the data required to create an order in the CDEK API.
11
+ # Each order includes attributes such as type, number, tariff code, locations, recipient, sender, and packages.
10
12
  class OrderData
11
13
  include Validatable
12
14
 
@@ -23,6 +25,21 @@ module CDEKApiClient
23
25
  validates :packages, type: :array, presence: true, items: [Package]
24
26
  validates :comment, type: :string
25
27
 
28
+ # Initializes a new OrderData object.
29
+ #
30
+ # @param type [Integer] the type of the order.
31
+ # @param number [String] the order number.
32
+ # @param tariff_code [Integer] the tariff code.
33
+ # @param from_location [Location] the location details from where the order is shipped.
34
+ # @param to_location [Location] the location details to where the order is shipped.
35
+ # @param recipient [Recipient] the recipient details.
36
+ # @param sender [Sender] the sender details.
37
+ # @param packages [Array<Package>] the list of packages.
38
+ # @param comment [String, nil] the comment for the order.
39
+ # @param shipment_point [String, nil] the shipment point.
40
+ # @param delivery_point [String, nil] the delivery point.
41
+ # @param services [Array, nil] additional services.
42
+ # @raise [ArgumentError] if any attribute validation fails.
26
43
  def initialize(type:, number:, tariff_code:, from_location:, to_location:, recipient:, sender:, packages:,
27
44
  comment: nil, shipment_point: nil, delivery_point: nil, services: [])
28
45
  @type = type
@@ -40,6 +57,9 @@ module CDEKApiClient
40
57
  validate!
41
58
  end
42
59
 
60
+ # Converts the OrderData object to a JSON representation.
61
+ #
62
+ # @return [String] the JSON representation of the OrderData.
43
63
  def to_json(*_args)
44
64
  {
45
65
  type: @type,
@@ -5,6 +5,8 @@ require_relative 'item'
5
5
 
6
6
  module CDEKApiClient
7
7
  module Entities
8
+ # Represents a package entity in the CDEK API.
9
+ # Each package includes attributes such as number, comment, height, length, weight, width, and items.
8
10
  class Package
9
11
  include Validatable
10
12
 
@@ -17,6 +19,16 @@ module CDEKApiClient
17
19
  validates :width, type: :integer, presence: true
18
20
  validates :items, type: :array, presence: true, items: [Item]
19
21
 
22
+ # Initializes a new Package object.
23
+ #
24
+ # @param number [String] the package number.
25
+ # @param comment [String] the comment for the package.
26
+ # @param height [Integer] the height of the package.
27
+ # @param length [Integer] the length of the package.
28
+ # @param weight [Integer] the weight of the package.
29
+ # @param width [Integer] the width of the package.
30
+ # @param items [Array<Item>] the list of items in the package.
31
+ # @raise [ArgumentError] if any attribute validation fails.
20
32
  def initialize(number:, comment:, height:, length:, weight:, width:, items:)
21
33
  @number = number
22
34
  @comment = comment
@@ -28,6 +40,9 @@ module CDEKApiClient
28
40
  validate!
29
41
  end
30
42
 
43
+ # Converts the Package object to a JSON representation.
44
+ #
45
+ # @return [String] the JSON representation of the Package.
31
46
  def to_json(*_args)
32
47
  {
33
48
  number: @number,
@@ -5,6 +5,8 @@ require_relative 'currency_mapper'
5
5
 
6
6
  module CDEKApiClient
7
7
  module Entities
8
+ # Represents a payment entity in the CDEK API.
9
+ # Each payment includes attributes such as value and currency.
8
10
  class Payment
9
11
  include Validatable
10
12
 
@@ -13,12 +15,20 @@ module CDEKApiClient
13
15
  validates :value, type: :integer, presence: true, positive: true
14
16
  validates :currency, type: :integer, presence: true
15
17
 
18
+ # Initializes a new Payment object.
19
+ #
20
+ # @param value [Integer] the payment value.
21
+ # @param currency [String] the currency code for the payment.
22
+ # @raise [ArgumentError] if any attribute validation fails.
16
23
  def initialize(value:, currency:)
17
24
  @value = value
18
- @currency = CDEKApiClient::Entities::CurrencyMapper.to_code(currency)
25
+ @currency = CurrencyMapper.to_code(currency)
19
26
  validate!
20
27
  end
21
28
 
29
+ # Converts the Payment object to a JSON representation.
30
+ #
31
+ # @return [String] the JSON representation of the Payment.
22
32
  def to_json(*_args)
23
33
  {
24
34
  value: @value,
@@ -4,6 +4,8 @@ require_relative 'validatable'
4
4
 
5
5
  module CDEKApiClient
6
6
  module Entities
7
+ # Represents a recipient entity in the CDEK API.
8
+ # Each recipient includes attributes such as name, phones, and email.
7
9
  class Recipient
8
10
  include Validatable
9
11
 
@@ -14,6 +16,12 @@ module CDEKApiClient
14
16
  presence: true
15
17
  validates :email, type: :string, presence: true
16
18
 
19
+ # Initializes a new Recipient object.
20
+ #
21
+ # @param name [String] the name of the recipient.
22
+ # @param phones [Array<Hash>] the list of phone numbers for the recipient.
23
+ # @param email [String] the email address of the recipient.
24
+ # @raise [ArgumentError] if any attribute validation fails.
17
25
  def initialize(name:, phones:, email:)
18
26
  @name = name
19
27
  @phones = phones
@@ -21,6 +29,9 @@ module CDEKApiClient
21
29
  validate!
22
30
  end
23
31
 
32
+ # Converts the Recipient object to a JSON representation.
33
+ #
34
+ # @return [String] the JSON representation of the Recipient.
24
35
  def to_json(*_args)
25
36
  {
26
37
  name: @name,
@@ -4,6 +4,8 @@ require_relative 'validatable'
4
4
 
5
5
  module CDEKApiClient
6
6
  module Entities
7
+ # Represents a sender entity in the CDEK API.
8
+ # Each sender includes attributes such as name, phones, and email.
7
9
  class Sender
8
10
  include Validatable
9
11
 
@@ -14,6 +16,12 @@ module CDEKApiClient
14
16
  presence: true
15
17
  validates :email, type: :string, presence: true
16
18
 
19
+ # Initializes a new Sender object.
20
+ #
21
+ # @param name [String] the name of the sender.
22
+ # @param phones [Array<Hash>] the list of phone numbers for the sender.
23
+ # @param email [String] the email address of the sender.
24
+ # @raise [ArgumentError] if any attribute validation fails.
17
25
  def initialize(name:, phones:, email:)
18
26
  @name = name
19
27
  @phones = phones
@@ -21,6 +29,9 @@ module CDEKApiClient
21
29
  validate!
22
30
  end
23
31
 
32
+ # Converts the Sender object to a JSON representation.
33
+ #
34
+ # @return [String] the JSON representation of the Sender.
24
35
  def to_json(*_args)
25
36
  {
26
37
  name: @name,
@@ -5,6 +5,8 @@ require_relative 'payment'
5
5
 
6
6
  module CDEKApiClient
7
7
  module Entities
8
+ # Represents a service entity in the CDEK API.
9
+ # Each service includes attributes such as code, price, and name.
8
10
  class Service
9
11
  include Validatable
10
12
 
@@ -14,6 +16,12 @@ module CDEKApiClient
14
16
  validates :price, type: :integer, presence: true
15
17
  validates :name, type: :string, presence: true
16
18
 
19
+ # Initializes a new Service object.
20
+ #
21
+ # @param code [String] the code of the service.
22
+ # @param price [Integer] the price of the service.
23
+ # @param name [String] the name of the service.
24
+ # @raise [ArgumentError] if any attribute validation fails.
17
25
  def initialize(code:, price:, name:)
18
26
  @code = code
19
27
  @price = price
@@ -21,6 +29,9 @@ module CDEKApiClient
21
29
  validate!
22
30
  end
23
31
 
32
+ # Converts the Service object to a JSON representation.
33
+ #
34
+ # @return [String] the JSON representation of the Service.
24
35
  def to_json(*_args)
25
36
  {
26
37
  code: @code,
@@ -5,6 +5,9 @@ require_relative 'currency_mapper'
5
5
 
6
6
  module CDEKApiClient
7
7
  module Entities
8
+ # Represents the data required to calculate a tariff in the CDEK API.
9
+ # Each tariff data includes attributes such as type, currency,
10
+ # from_location, to_location, packages, and tariff_code.
8
11
  class TariffData
9
12
  include Validatable
10
13
 
@@ -17,6 +20,15 @@ module CDEKApiClient
17
20
  validates :to_location, type: :object, presence: true
18
21
  validates :packages, type: :array, presence: true, items: [Package]
19
22
 
23
+ # Initializes a new TariffData object.
24
+ #
25
+ # @param type [Integer] the type of the tariff.
26
+ # @param currency [String] the currency code of the tariff.
27
+ # @param from_location [Location] the location from which the tariff calculation starts.
28
+ # @param to_location [Location] the destination location for the tariff calculation.
29
+ # @param packages [Array<Package>] the list of packages included in the tariff calculation.
30
+ # @param tariff_code [Integer] the tariff code.
31
+ # @raise [ArgumentError] if any attribute validation fails.
20
32
  def initialize(type:, currency:, from_location:, to_location:, packages:, tariff_code:)
21
33
  @type = type
22
34
  @currency = CurrencyMapper.to_code(currency)
@@ -27,6 +39,9 @@ module CDEKApiClient
27
39
  validate!
28
40
  end
29
41
 
42
+ # Converts the TariffData object to a JSON representation.
43
+ #
44
+ # @return [String] the JSON representation of the TariffData.
30
45
  def to_json(*_args)
31
46
  {
32
47
  type: @type,
@@ -1,23 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Validatable module provides validation capabilities for entities.
3
4
  module CDEKApiClient
4
5
  module Entities
6
+ # This module provides validation capabilities for entities.
7
+ # It allows for presence and type validations on attributes.
5
8
  module Validatable
6
9
  def self.included(base)
7
10
  base.extend ClassMethods
8
11
  end
9
12
 
13
+ # Class methods for the Validatable module.
10
14
  module ClassMethods
15
+ # Defines validations for attributes.
16
+ #
17
+ # @param attribute [Symbol] the name of the attribute to validate.
18
+ # @param options [Hash] the validation options.
19
+ # @option options [Symbol] :type the expected type of the attribute.
20
+ # @option options [Boolean] :presence whether the attribute is required.
11
21
  def validates(attribute, options)
12
22
  @validations ||= {}
13
23
  @validations[attribute] = options
14
24
  end
15
25
 
26
+ # Returns the defined validations.
27
+ #
28
+ # @return [Hash] the defined validations.
16
29
  def validations
17
30
  @validations
18
31
  end
19
32
  end
20
33
 
34
+ # Validates the entity's attributes based on the defined validations.
35
+ #
36
+ # @raise [RuntimeError] if any validation fails.
21
37
  def validate!
22
38
  self.class.validations.each do |attribute, rule|
23
39
  value = send(attribute)
@@ -28,22 +44,30 @@ module CDEKApiClient
28
44
 
29
45
  private
30
46
 
47
+ # Validates the presence of an attribute.
48
+ #
49
+ # @param attribute [Symbol] the name of the attribute.
50
+ # @param value [Object] the value of the attribute.
51
+ # @param rule [Hash] the validation rule.
52
+ # @raise [RuntimeError] if the validation fails.
31
53
  def validate_presence(attribute, value, rule)
32
54
  raise "#{attribute} is required" if rule[:presence] && value.nil?
33
55
  end
34
56
 
57
+ # Validates the type of an attribute.
58
+ #
59
+ # @param attribute [Symbol] the name of the attribute.
60
+ # @param value [Object] the value of the attribute.
61
+ # @param rule [Hash] the validation rule.
62
+ # @raise [RuntimeError] if the validation fails.
35
63
  def validate_type(attribute, value, rule)
36
64
  case rule[:type]
37
65
  when :string
38
- raise "#{attribute} must be a String" unless value.is_a?(String)
66
+ validate_string(attribute, value)
39
67
  when :integer
40
- raise "#{attribute} must be an Integer" unless value.is_a?(Integer)
41
-
42
- validate_positive(attribute, value, rule)
68
+ validate_integer(attribute, value, rule)
43
69
  when :array
44
- raise "#{attribute} must be an Array" unless value.is_a?(Array)
45
-
46
- validate_array_items(attribute, value, rule)
70
+ validate_array(attribute, value, rule)
47
71
  when :object
48
72
  validate_object(attribute, value, rule)
49
73
  when :hash
@@ -51,10 +75,55 @@ module CDEKApiClient
51
75
  end
52
76
  end
53
77
 
78
+ # Validates that a value is a string.
79
+ #
80
+ # @param attribute [Symbol] the name of the attribute.
81
+ # @param value [Object] the value of the attribute.
82
+ # @raise [RuntimeError] if the validation fails.
83
+ def validate_string(attribute, value)
84
+ raise "#{attribute} must be a String" unless value.is_a?(String)
85
+ end
86
+
87
+ # Validates that a value is an integer and optionally that it is positive.
88
+ #
89
+ # @param attribute [Symbol] the name of the attribute.
90
+ # @param value [Integer] the value of the attribute.
91
+ # @param rule [Hash] the validation rule.
92
+ # @raise [RuntimeError] if the validation fails.
93
+ def validate_integer(attribute, value, rule)
94
+ raise "#{attribute} must be an Integer" unless value.is_a?(Integer)
95
+
96
+ validate_positive(attribute, value, rule)
97
+ end
98
+
99
+ # Validates that a value is an array and its items.
100
+ #
101
+ # @param attribute [Symbol] the name of the attribute.
102
+ # @param array [Array] the value of the attribute.
103
+ # @param rule [Hash] the validation rule.
104
+ # @raise [RuntimeError] if the validation fails.
105
+ def validate_array(attribute, array, rule)
106
+ raise "#{attribute} must be an Array" unless array.is_a?(Array)
107
+
108
+ validate_array_items(attribute, array, rule)
109
+ end
110
+
111
+ # Validates that a value is positive.
112
+ #
113
+ # @param attribute [Symbol] the name of the attribute.
114
+ # @param value [Integer] the value of the attribute.
115
+ # @param rule [Hash] the validation rule.
116
+ # @raise [RuntimeError] if the validation fails.
54
117
  def validate_positive(attribute, value, rule)
55
118
  raise "#{attribute} must be a positive number" if rule[:positive] && value <= 0
56
119
  end
57
120
 
121
+ # Validates the items of an array.
122
+ #
123
+ # @param attribute [Symbol] the name of the attribute.
124
+ # @param array [Array] the value of the attribute.
125
+ # @param rule [Hash] the validation rule.
126
+ # @raise [RuntimeError] if the validation fails.
58
127
  def validate_array_items(attribute, array, rule)
59
128
  array.each do |item|
60
129
  if item.is_a?(Hash)
@@ -70,6 +139,12 @@ module CDEKApiClient
70
139
  end
71
140
  end
72
141
 
142
+ # Validates an object.
143
+ #
144
+ # @param _attribute [Symbol] the name of the attribute.
145
+ # @param object [Object] the value of the attribute.
146
+ # @param _rule [Hash] the validation rule.
147
+ # @raise [RuntimeError] if the validation fails.
73
148
  def validate_object(_attribute, object, _rule)
74
149
  object.class.validations.each do |attr, validation_rule|
75
150
  value = object.send(attr)
@@ -78,6 +153,12 @@ module CDEKApiClient
78
153
  end
79
154
  end
80
155
 
156
+ # Validates a hash.
157
+ #
158
+ # @param _attribute [Symbol] the name of the attribute.
159
+ # @param hash [Hash] the value of the attribute.
160
+ # @param rule [Hash] the validation rule.
161
+ # @raise [RuntimeError] if the validation fails.
81
162
  def validate_hash(_attribute, hash, rule)
82
163
  rule[:schema].each do |attr, validation_rule|
83
164
  value = hash[attr]
@@ -4,6 +4,8 @@ require_relative 'validatable'
4
4
 
5
5
  module CDEKApiClient
6
6
  module Entities
7
+ # Represents a webhook entity in the CDEK API.
8
+ # Each webhook includes attributes such as url, type, and event types.
7
9
  class Webhook
8
10
  include Validatable
9
11
 
@@ -13,6 +15,12 @@ module CDEKApiClient
13
15
  validates :type, type: :string, presence: true
14
16
  validates :event_types, type: :array, presence: true, items: [{ type: :string, presence: true }]
15
17
 
18
+ # Initializes a new Webhook object.
19
+ #
20
+ # @param url [String] the URL where the webhook will send data.
21
+ # @param type [String] the type of webhook.
22
+ # @param event_types [Array<String>] the list of event types for the webhook.
23
+ # @raise [ArgumentError] if any attribute validation fails.
16
24
  def initialize(url:, type:, event_types:)
17
25
  @url = url
18
26
  @type = type
@@ -20,6 +28,9 @@ module CDEKApiClient
20
28
  validate!
21
29
  end
22
30
 
31
+ # Converts the Webhook object to a JSON representation.
32
+ #
33
+ # @return [String] the JSON representation of the Webhook.
23
34
  def to_json(*_args)
24
35
  {
25
36
  url: @url,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CDEKApiClient
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.1'
5
5
  end
@@ -1,36 +1,64 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'cdek_api_client/api/location'
4
+ require_relative 'cdek_api_client/api/order'
5
+ require_relative 'cdek_api_client/api/tariff'
6
+ require_relative 'cdek_api_client/api/track_order'
7
+ require_relative 'cdek_api_client/api/webhook'
3
8
  require_relative 'cdek_api_client/client'
4
- require_relative 'cdek_api_client/order'
5
- require_relative 'cdek_api_client/track_order'
6
- require_relative 'cdek_api_client/tariff'
7
- require_relative 'cdek_api_client/version'
8
- require_relative 'cdek_api_client/location'
9
- require_relative 'cdek_api_client/webhook'
10
- require_relative 'cdek_api_client/entities/order_data'
9
+ require_relative 'cdek_api_client/entities/currency_mapper'
10
+ require_relative 'cdek_api_client/entities/item'
11
11
  require_relative 'cdek_api_client/entities/location'
12
+ require_relative 'cdek_api_client/entities/order_data'
12
13
  require_relative 'cdek_api_client/entities/package'
14
+ require_relative 'cdek_api_client/entities/payment'
13
15
  require_relative 'cdek_api_client/entities/recipient'
14
- require_relative 'cdek_api_client/entities/item'
15
- require_relative 'cdek_api_client/entities/validatable'
16
16
  require_relative 'cdek_api_client/entities/sender'
17
- require_relative 'cdek_api_client/entities/currency_mapper'
18
- require_relative 'cdek_api_client/entities/tariff_data'
19
- require_relative 'cdek_api_client/entities/payment'
20
17
  require_relative 'cdek_api_client/entities/service'
18
+ require_relative 'cdek_api_client/entities/tariff_data'
19
+ require_relative 'cdek_api_client/entities/validatable'
21
20
  require_relative 'cdek_api_client/entities/webhook'
21
+ require_relative 'cdek_api_client/version'
22
+
23
+ # frozen_string_literal: true
22
24
 
25
+ # CDEKApiClient is a Ruby client for interacting with the CDEK API.
26
+ # It provides functionalities for order creation, tracking, tariff calculation,
27
+ # location data retrieval, and webhook management. This gem ensures clean,
28
+ # robust, and maintainable code with proper validations.
29
+ #
30
+ # To use this gem, configure it with your CDEK API client ID and secret,
31
+ # and then access various API functionalities through the provided client.
32
+ #
33
+ # Example:
34
+ # CDEKApiClient.configure do |config|
35
+ # config.client_id = 'your_client_id'
36
+ # config.client_secret = 'your_client_secret'
37
+ # end
38
+ # client = CDEKApiClient.client
39
+ #
40
+ # For more details, refer to the README.
23
41
  module CDEKApiClient
24
42
  class Error < StandardError; end
25
43
 
26
44
  class << self
45
+ # Configures the client with the provided block.
46
+ # @yield [self] Yields the client to the provided block.
27
47
  def configure
28
48
  yield self
29
49
  end
30
50
 
31
- attr_accessor :client_id, :client_secret
51
+ # @!attribute [rw] client_id
52
+ # @return [String] The client ID for authentication.
53
+ attr_accessor :client_id
54
+
55
+ # @!attribute [rw] client_secret
56
+ # @return [String] The client secret for authentication.
57
+ attr_accessor :client_secret
32
58
  end
33
59
 
60
+ # Returns the CDEK API client.
61
+ # @return [CDEKApiClient::Client] The CDEK API client instance.
34
62
  def self.client
35
63
  @client ||= CDEKApiClient::Client.new(client_id, client_secret)
36
64
  end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdek_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damir Mukimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-20 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: base64
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.2.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.2.0
27
- - !ruby/object:Gem::Dependency
28
- name: faraday
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 1.10.3
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 1.10.3
41
- - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 1.2.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 1.2.0
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: This gem provides a Ruby client for interacting with the CDEK API, including
56
14
  order creation, tracking, and tariff calculation.
57
15
  email:
@@ -62,6 +20,11 @@ extra_rdoc_files: []
62
20
  files:
63
21
  - README.md
64
22
  - lib/cdek_api_client.rb
23
+ - lib/cdek_api_client/api/location.rb
24
+ - lib/cdek_api_client/api/order.rb
25
+ - lib/cdek_api_client/api/tariff.rb
26
+ - lib/cdek_api_client/api/track_order.rb
27
+ - lib/cdek_api_client/api/webhook.rb
65
28
  - lib/cdek_api_client/client.rb
66
29
  - lib/cdek_api_client/entities/currency_mapper.rb
67
30
  - lib/cdek_api_client/entities/item.rb
@@ -75,13 +38,7 @@ files:
75
38
  - lib/cdek_api_client/entities/tariff_data.rb
76
39
  - lib/cdek_api_client/entities/validatable.rb
77
40
  - lib/cdek_api_client/entities/webhook.rb
78
- - lib/cdek_api_client/location.rb
79
- - lib/cdek_api_client/order.rb
80
- - lib/cdek_api_client/recipient.rb
81
- - lib/cdek_api_client/tariff.rb
82
- - lib/cdek_api_client/track_order.rb
83
41
  - lib/cdek_api_client/version.rb
84
- - lib/cdek_api_client/webhook.rb
85
42
  homepage: http://glowing-pixels.com/cdek_api_client
86
43
  licenses:
87
44
  - MIT
@@ -89,7 +46,8 @@ metadata:
89
46
  github_repo: git@github.com/SamyRai/cdek_api_client.git
90
47
  homepage_uri: http://glowing-pixels.com/cdek_api_client
91
48
  source_code_uri: http://github.com/SamyRai/cdek_api_client
92
- changelog_uri: http://www.glowing-pixels.com/cdek_api_client/CHANGELOG.md
49
+ changelog_uri: https://github.com/SamyRai/cdek_api_client?tab=readme-ov-file#changelog
50
+ rubygems_mfa_required: 'true'
93
51
  post_install_message:
94
52
  rdoc_options: []
95
53
  require_paths:
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CDEKApiClient
4
- class Location
5
- CITIES_URL = 'location/cities'
6
- REGIONS_URL = 'location/regions'
7
-
8
- def initialize(client)
9
- @client = client
10
- end
11
-
12
- def cities
13
- response = @client.auth_connection.get(CITIES_URL) do |req|
14
- req.headers['Content-Type'] = 'application/json'
15
- end
16
- handle_response(response)
17
- end
18
-
19
- def regions
20
- response = @client.auth_connection.get(REGIONS_URL) do |req|
21
- req.headers['Content-Type'] = 'application/json'
22
- end
23
- handle_response(response)
24
- end
25
-
26
- private
27
-
28
- def handle_response(response)
29
- @client.send(:handle_response, response)
30
- end
31
- end
32
- end