econt 0.1.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +17 -0
- data/CONTRIBUTING.md +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +171 -0
- data/SECURITY.md +33 -0
- data/docs/API.md +571 -0
- data/docs/ENDPOINTS.md +42 -0
- data/docs/PUBLIC_API.md +81 -0
- data/docs/RELEASING.md +35 -0
- data/docs/RESPONSE_TESTS.md +46 -0
- data/docs/VCR.md +144 -0
- data/lib/econt/camel_case_middleware.rb +88 -0
- data/lib/econt/client.rb +99 -0
- data/lib/econt/collection.rb +59 -0
- data/lib/econt/error.rb +42 -0
- data/lib/econt/meta_resource.rb +6 -0
- data/lib/econt/model.rb +95 -0
- data/lib/econt/models/error.rb +53 -0
- data/lib/econt/models/hosted_file.rb +13 -0
- data/lib/econt/models/nomenclatures/address.rb +35 -0
- data/lib/econt/models/nomenclatures/address_service_info.rb +16 -0
- data/lib/econt/models/nomenclatures/address_service_times_response.rb +19 -0
- data/lib/econt/models/nomenclatures/address_validation_response.rb +19 -0
- data/lib/econt/models/nomenclatures/city.rb +32 -0
- data/lib/econt/models/nomenclatures/country.rb +16 -0
- data/lib/econt/models/nomenclatures/geo_location.rb +13 -0
- data/lib/econt/models/nomenclatures/office.rb +32 -0
- data/lib/econt/models/nomenclatures/quarter.rb +14 -0
- data/lib/econt/models/nomenclatures/serving_office_element.rb +12 -0
- data/lib/econt/models/nomenclatures/street.rb +14 -0
- data/lib/econt/models/nomenclatures/working_date_time.rb +16 -0
- data/lib/econt/models/nomenclatures/working_time.rb +12 -0
- data/lib/econt/models/payment_report/payment_report_row.rb +17 -0
- data/lib/econt/models/profile/cd_pay_options.rb +24 -0
- data/lib/econt/models/profile/client_profile.rb +29 -0
- data/lib/econt/models/profile/profiles_response_element.rb +16 -0
- data/lib/econt/models/shipments/cargo_vehicle_options.rb +16 -0
- data/lib/econt/models/shipments/check_possible_shipment_editions_result_element.rb +14 -0
- data/lib/econt/models/shipments/create_label_result_element.rb +19 -0
- data/lib/econt/models/shipments/customs_list_element.rb +14 -0
- data/lib/econt/models/shipments/delete_labels_result_element.rb +14 -0
- data/lib/econt/models/shipments/get_my_awb_response.rb +15 -0
- data/lib/econt/models/shipments/get_my_awb_result_element.rb +23 -0
- data/lib/econt/models/shipments/instruction.rb +20 -0
- data/lib/econt/models/shipments/next_shipment_element.rb +13 -0
- data/lib/econt/models/shipments/pack_element.rb +14 -0
- data/lib/econt/models/shipments/packing_list_element.rb +17 -0
- data/lib/econt/models/shipments/payment_addition_price.rb +14 -0
- data/lib/econt/models/shipments/payment_instruction.rb +11 -0
- data/lib/econt/models/shipments/previous_shipment.rb +14 -0
- data/lib/econt/models/shipments/request_courier_response.rb +13 -0
- data/lib/econt/models/shipments/request_courier_status.rb +14 -0
- data/lib/econt/models/shipments/request_courier_status_result_element.rb +14 -0
- data/lib/econt/models/shipments/return_instruction_params.rb +48 -0
- data/lib/econt/models/shipments/shipment_edition_response_element.rb +16 -0
- data/lib/econt/models/shipments/shipment_status.rb +64 -0
- data/lib/econt/models/shipments/shipment_status_result_element.rb +14 -0
- data/lib/econt/models/shipments/shipment_status_service.rb +16 -0
- data/lib/econt/models/shipments/shipment_tracking_event.rb +21 -0
- data/lib/econt/models/shipments/shipping_label.rb +59 -0
- data/lib/econt/models/shipments/shipping_label_services.rb +37 -0
- data/lib/econt/models/shipments/status_response.rb +11 -0
- data/lib/econt/models/shipments/update_label_response.rb +11 -0
- data/lib/econt/models/shipments/update_labels_result_element.rb +14 -0
- data/lib/econt/models/three_way_logistics/three_way_logistics.rb +50 -0
- data/lib/econt/models/three_way_logistics/three_way_logistics_response.rb +11 -0
- data/lib/econt/resource_attributes.rb +69 -0
- data/lib/econt/service_resource.rb +105 -0
- data/lib/econt/services/nomenclatures/address.rb +87 -0
- data/lib/econt/services/nomenclatures/nomenclatures.rb +122 -0
- data/lib/econt/services/nomenclatures.rb +11 -0
- data/lib/econt/services/payment_report/payment_report.rb +35 -0
- data/lib/econt/services/payment_report.rb +11 -0
- data/lib/econt/services/profile/profile.rb +45 -0
- data/lib/econt/services/profile.rb +11 -0
- data/lib/econt/services/shipments/label.rb +174 -0
- data/lib/econt/services/shipments/shipment.rb +109 -0
- data/lib/econt/services/shipments.rb +11 -0
- data/lib/econt/services/three_way_logistics/three_way_logistics.rb +30 -0
- data/lib/econt/services/three_way_logistics.rb +11 -0
- data/lib/econt/util.rb +63 -0
- data/lib/econt/version.rb +5 -0
- data/lib/econt.rb +118 -0
- data/sig/econt.rbs +465 -0
- metadata +166 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 72d630d421e9bfb7d741ba051f81722c740f251fd6d50e2d66b98fb73d1aba4f
|
|
4
|
+
data.tar.gz: a1c465eaf16fecc9a83f114d0e5403de12e2af41d24b7a2381cde2a3d1968165
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cc999dd5f5f08b1468d56444500a5b623a56a16a3f805757db5899a8365dbc56315ea9a5139d5f3768b54a076bcfe16735166030d4c5794c91efcd6808d26dbf
|
|
7
|
+
data.tar.gz: 553ef848b6016d4d1635dba09e8a7f27c0b6aca61ac3f974a31d62c9f47bfe34e2451d132a90dfc76477f0d5cd81e8363c735a7cd97a28e87fdae1072f603211
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Code of conduct
|
|
2
|
+
|
|
3
|
+
Be respectful, constructive, and patient in project discussions. Harassment,
|
|
4
|
+
discrimination, threats, publication of another person's private information,
|
|
5
|
+
and intentionally disruptive behavior are not accepted.
|
|
6
|
+
|
|
7
|
+
Maintainers may edit or remove comments, issues, pull requests, and other
|
|
8
|
+
contributions that violate these expectations, and may temporarily or
|
|
9
|
+
permanently restrict participation when necessary.
|
|
10
|
+
|
|
11
|
+
Report conduct concerns through GitHub's private reporting facilities when
|
|
12
|
+
available. If no private channel is available, open an issue asking the
|
|
13
|
+
maintainer to establish one without including sensitive details.
|
|
14
|
+
|
|
15
|
+
This is a small, volunteer-maintained project. Disagreement about a technical
|
|
16
|
+
decision is welcome when it stays focused on the work and treats participants
|
|
17
|
+
with respect.
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for improving this community-maintained Econt client.
|
|
4
|
+
|
|
5
|
+
## Support expectations
|
|
6
|
+
|
|
7
|
+
Issues and pull requests are reviewed on a best-effort basis, usually on
|
|
8
|
+
weekends. There is no guaranteed response time, service-level agreement, or
|
|
9
|
+
commitment to implement feature requests. Focused pull requests for fixes and
|
|
10
|
+
documented endpoints are welcome. The MIT license also permits you to fork and
|
|
11
|
+
maintain behavior tailored to your application.
|
|
12
|
+
|
|
13
|
+
Use GitHub Issues for reproducible bugs, documentation gaps, and focused feature
|
|
14
|
+
proposals. Include the gem version, Ruby version, environment (demo or
|
|
15
|
+
production), the service method, expected behavior, and a minimal sanitized
|
|
16
|
+
example. Never include credentials, Authorization headers, real names, phone
|
|
17
|
+
numbers, addresses, shipment numbers, or unredacted carrier responses.
|
|
18
|
+
|
|
19
|
+
Security vulnerabilities belong in the private process described in
|
|
20
|
+
[SECURITY.md](SECURITY.md), not in a public issue.
|
|
21
|
+
|
|
22
|
+
## Pull requests
|
|
23
|
+
|
|
24
|
+
1. Open an issue first for a public API change or a large addition.
|
|
25
|
+
2. Keep changes focused and preserve Econt's documented casing at the HTTP
|
|
26
|
+
boundary while exposing snake_case Ruby APIs.
|
|
27
|
+
3. Add request-payload and response-model specs.
|
|
28
|
+
4. Update RBS and public documentation when the API changes.
|
|
29
|
+
5. Run `bundle exec rake`, `bundle exec rbs validate`, and
|
|
30
|
+
`bin/package_smoke_test`.
|
|
31
|
+
|
|
32
|
+
Normal tests must not contact Econt. Contract recordings are opt-in, must use
|
|
33
|
+
the demo environment, and must be carefully scrubbed before they are proposed.
|
|
34
|
+
Do not record state-changing label or courier operations without prior project
|
|
35
|
+
discussion.
|
|
36
|
+
|
|
37
|
+
By participating, you agree to follow [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Boyan Georgiev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Econt
|
|
2
|
+
|
|
3
|
+
A Ruby client for Econt's EEcont JSON API, with snake_case request keys,
|
|
4
|
+
typed responses, Basic authentication, and configurable timeouts.
|
|
5
|
+
|
|
6
|
+
Only JSON endpoints are supported; SOAP is not supported.
|
|
7
|
+
|
|
8
|
+
Community maintained; not affiliated with or endorsed by Econt.
|
|
9
|
+
See the [official API documentation](http://ee.econt.com/services/) for account
|
|
10
|
+
access and required fields.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Requires Ruby 3.3 or later; CI tests Ruby 3.3, 3.4, and 4.0.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bundle add econt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
Econt::Client.configure do |config|
|
|
24
|
+
config.username = ENV.fetch('ECONT_USERNAME')
|
|
25
|
+
config.password = ENV.fetch('ECONT_PASSWORD')
|
|
26
|
+
# Demo is the default. Use this URL for production:
|
|
27
|
+
config.base_url = 'http://ee.econt.com/services/'
|
|
28
|
+
config.open_timeout = 10
|
|
29
|
+
config.read_timeout = 30
|
|
30
|
+
config.write_timeout = 30
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Transport warning:** Econt documents HTTP service endpoints. Basic credentials
|
|
35
|
+
and shipment data are transmitted without TLS. Use a trusted server-side network
|
|
36
|
+
path and assess this risk before production use; never call the API from browser
|
|
37
|
+
code. Demo uses `http://demo.econt.com/ee/services/`, with separate credentials.
|
|
38
|
+
The client does not replace documented URLs with HTTPS.
|
|
39
|
+
|
|
40
|
+
### Rails initializer
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# config/initializers/econt.rb
|
|
44
|
+
Econt::Client.configure do |config|
|
|
45
|
+
config.username = Rails.application.credentials.dig(:econt, :username)
|
|
46
|
+
config.password = Rails.application.credentials.dig(:econt, :password)
|
|
47
|
+
config.base_url = ENV.fetch('ECONT_BASE_URL', 'http://demo.econt.com/ee/services/')
|
|
48
|
+
end
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Debug logging is opt-in with `config.debug = true` and
|
|
52
|
+
`config.debug_logger = Rails.logger`. Credentials are filtered; bodies are
|
|
53
|
+
excluded by default. `config.debug_bodies = true` can expose personal and
|
|
54
|
+
commercial data—use only for controlled local investigation.
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
Requests use snake_case keys; responses expose snake_case readers and `to_h`.
|
|
59
|
+
|
|
60
|
+
```ruby
|
|
61
|
+
nomenclatures = Econt::Services::Nomenclatures::Nomenclatures.new
|
|
62
|
+
cities = nomenclatures.get_cities(country_code: 'BGR')
|
|
63
|
+
offices = nomenclatures.get_offices(country_code: 'BGR', city_id: cities.first.id)
|
|
64
|
+
|
|
65
|
+
addresses = Econt::Services::Nomenclatures::Address.new
|
|
66
|
+
result = addresses.validate_address(
|
|
67
|
+
city: { country: { code3: 'BGR' }, name: 'София', post_code: '1000' },
|
|
68
|
+
street: 'Витоша', num: '1'
|
|
69
|
+
)
|
|
70
|
+
result.validation_status
|
|
71
|
+
result.address
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Labels and tracking
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
labels = Econt::Services::Shipments::Label.new
|
|
78
|
+
quote = labels.create_label(
|
|
79
|
+
mode: 'calculate',
|
|
80
|
+
label: {
|
|
81
|
+
sender_client: { name: 'Sender', phones: ['+359888000000'] },
|
|
82
|
+
sender_office_code: '1000',
|
|
83
|
+
receiver_client: { name: 'Receiver', phones: ['+359888000001'] },
|
|
84
|
+
receiver_office_code: '1000',
|
|
85
|
+
shipment_type: 'pack', pack_count: 1, weight: 1.2,
|
|
86
|
+
shipment_description: 'Artwork'
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
quote.label.total_price
|
|
90
|
+
quote.label.currency
|
|
91
|
+
|
|
92
|
+
shipments = Econt::Services::Shipments::Shipment.new
|
|
93
|
+
statuses = shipments.get_shipment_statuses(shipment_numbers: ['1234567890123'])
|
|
94
|
+
statuses.first.status
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Label modes include `calculate`, `validate`, `create`, and single-label
|
|
98
|
+
`calculate_with_block`. Creation and other mutations have real effects in the
|
|
99
|
+
selected environment. Example office codes and payloads must be adapted to your
|
|
100
|
+
account and shipment.
|
|
101
|
+
|
|
102
|
+
See the [Ruby API reference](docs/API.md) for every service method, its parameters,
|
|
103
|
+
return value, safety notes, and examples. The [endpoint matrix](docs/ENDPOINTS.md)
|
|
104
|
+
maps these methods to carrier operations; see the
|
|
105
|
+
[public API contract](docs/PUBLIC_API.md) for conversions and known limitations.
|
|
106
|
+
|
|
107
|
+
## Error handling
|
|
108
|
+
|
|
109
|
+
Transport and HTTP failures raise `Econt::Error`. Models and collections also
|
|
110
|
+
expose `error?` and `error` for carrier errors returned in a response.
|
|
111
|
+
|
|
112
|
+
Connection, timeout, and TLS failures use `Econt::ConnectionError`,
|
|
113
|
+
`Econt::TimeoutError`, and `Econt::SSLError`, under `Econt::TransportError`.
|
|
114
|
+
They have safe fixed messages; their original `cause` and `full_message` can
|
|
115
|
+
contain private data. There are no automatic retries, especially for mutations.
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
begin
|
|
119
|
+
result = labels.create_label(mode: 'validate', label: label_payload)
|
|
120
|
+
Rails.logger.warn(result.error.full_message) if result.error?
|
|
121
|
+
rescue Econt::Error => error
|
|
122
|
+
Rails.logger.warn("Econt request failed (status=#{error.status.inspect})")
|
|
123
|
+
# Present an application-owned message; retry only when safe.
|
|
124
|
+
end
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Review carrier error contents before logging or displaying them to customers.
|
|
128
|
+
|
|
129
|
+
## Versioning and support
|
|
130
|
+
|
|
131
|
+
We follow [Semantic Versioning](https://semver.org/). Before 1.0, minor releases
|
|
132
|
+
may change the public API incompatibly. From 1.0, incompatible changes to the
|
|
133
|
+
documented API require a major release.
|
|
134
|
+
|
|
135
|
+
There is no support SLA. Issues and PRs are reviewed best-effort, usually on
|
|
136
|
+
weekends. Fixes with tests are welcome; the MIT license permits maintaining a
|
|
137
|
+
fork. See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
bin/setup
|
|
143
|
+
bundle exec rake
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Offline tests cover request payloads and example-response mapping. See
|
|
147
|
+
[response tests](docs/RESPONSE_TESTS.md) for their scope and limitations.
|
|
148
|
+
Reviewed VCR recordings are replayed in CI with recording and network access
|
|
149
|
+
disabled; missing recordings are not fetched automatically.
|
|
150
|
+
|
|
151
|
+
To run the same credential-free replay locally:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
ECONT_VCR_REPLAY=1 bundle exec rspec spec/recorded_contract_spec.rb
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
For deliberate demo recording, copy `.env.example` to `.env.test`, configure
|
|
158
|
+
credentials, and run:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
ECONT_LIVE_TESTS=1 bundle exec rspec spec/live
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The create/delete/status lifecycle requires `ECONT_MUTATING_LIVE_TESTS=1` as
|
|
165
|
+
well. Other unsafe mutations remain offline-tested. Review all recordings before
|
|
166
|
+
committing; see [VCR policy and cleanup paths](docs/VCR.md) and
|
|
167
|
+
[release instructions](docs/RELEASING.md).
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
[MIT](LICENSE.txt).
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Use GitHub's private vulnerability reporting for this repository when it is
|
|
6
|
+
available. If it is not enabled, open a public issue containing only a request
|
|
7
|
+
for a private contact channel—do not include exploit details, credentials,
|
|
8
|
+
personal data, or carrier responses in that issue.
|
|
9
|
+
|
|
10
|
+
Reports are reviewed on a best-effort basis, usually on weekends. This
|
|
11
|
+
community project cannot promise a response or remediation deadline. Please do
|
|
12
|
+
not publicly disclose an unresolved vulnerability before a private discussion
|
|
13
|
+
has taken place.
|
|
14
|
+
|
|
15
|
+
Only the latest released version receives security fixes. Pull requests are
|
|
16
|
+
welcome after coordinated disclosure.
|
|
17
|
+
|
|
18
|
+
## Econt transport limitation
|
|
19
|
+
|
|
20
|
+
Econt documents its demo and production service URLs as HTTP endpoints using
|
|
21
|
+
HTTP Basic authentication. Consequently, credentials and shipment data are not
|
|
22
|
+
protected by TLS in transit. This gem preserves those documented URLs and does
|
|
23
|
+
not claim to solve that carrier-side limitation.
|
|
24
|
+
|
|
25
|
+
Run requests only from trusted server-side infrastructure and through a network
|
|
26
|
+
path whose risks you accept. Never call Econt directly from browser code. Keep
|
|
27
|
+
credentials out of source control, rotate them if exposed, and limit access to
|
|
28
|
+
application logs and VCR cassettes.
|
|
29
|
+
|
|
30
|
+
Debug mode filters the configured username, password, and Basic token. Request
|
|
31
|
+
and response bodies are disabled by default because they may contain personal
|
|
32
|
+
data. Enabling `debug_bodies` is an explicit decision to log that data and
|
|
33
|
+
should be limited to short-lived local diagnosis.
|