post_nord_api 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1bcbd60841f70094e13e09813ddb4ef6cc260b4f9154177444a5f12d0c6ed1a
4
- data.tar.gz: 1e6a5260fbe3b11bdbfcfbeb057c2f114a21193f14b6ea0ce39bf9d06bba5650
3
+ metadata.gz: b11f236215030650ce9b653eec6025ffd9c7b0394bd3187f3fb76b5c59951cf6
4
+ data.tar.gz: 07df89fb8acbdb7591d54e7f57dfeaaaf0074f7ace8b456ac2ff45eb7720b158
5
5
  SHA512:
6
- metadata.gz: 8bcbd947d4c9fcff05e848652fd83e1542f67bef5bd7a68bb96ba690fb8d94d3e4ecff2ed7ed8c426add57938dd5a414d326ff44b37a5415000c3774afbcc966
7
- data.tar.gz: cda788cfc5e43d3f879f50535e8c32c0e9208b3b6b993af98f27da0da8299d6691fbddbb211a328261fe5ab2b06992ca299e74ff91f88cc87bf4d74cb237e07b
6
+ metadata.gz: 39174553c880e834bca5fac1699cbf3b77ca0605b36f352f0e5270bbee5f2c60c8b7052499eb6b70b4a88442499cd0416abe97c2996b6a91e806b63fa0a2cb4c
7
+ data.tar.gz: b15e6ef19b40aa557fc25120130cd94af08faeb47c24b61185908d44729278a7fdae49f0c87a2997e94eff713ddf7c02d6a503f033248329ccce7bdd0dde0b4d
data/README.md CHANGED
@@ -45,99 +45,99 @@ client = PostNordAPI::Client.new(api_key: "api_key", test_mode: true)
45
45
  begin
46
46
  client = PostNordAPI::Client.new(api_key: "api_key")
47
47
  params = {
48
- "messageDate": '2025-09-23T11:40:52Z',
49
- "messageFunction": 'Instruction',
50
- "messageId": 'msg-18272155',
48
+ "message_date": '2025-09-23T11:40:52Z',
49
+ "message_function": 'Instruction',
50
+ "message_id": 'msg-18272155',
51
51
  "application": {
52
- "applicationId": 1438,
52
+ "application_id": 1438,
53
53
  "name": 'PostNord',
54
54
  "version": '1.0'
55
55
  },
56
56
  "language": 'EN',
57
- "updateIndicator": 'Original',
57
+ "update_indicator": 'Original',
58
58
  "shipment": [
59
59
  {
60
- "shipmentIdentification": {
61
- "shipmentId": '0'
60
+ "shipment_identification": {
61
+ "shipment_id": '0'
62
62
  },
63
- "dateAndTimes": {
64
- "loadingDate": '2020-11-29T11:13:00'
63
+ "date_and_times": {
64
+ "loading_date": '2020-11-29T11:13:00'
65
65
  },
66
66
  "service": {
67
- "basicServiceCode": '24',
68
- "additionalServiceCode": []
67
+ "basic_service_code": '24',
68
+ "additional_service_code": []
69
69
  },
70
- "numberOfPackages": {
70
+ "number_of_packages": {
71
71
  "value": 1
72
72
  },
73
- "totalGrossWeight": {
73
+ "total_gross_weight": {
74
74
  "value": 5.23,
75
75
  "unit": 'KGM'
76
76
  },
77
77
  "references": [
78
78
  {
79
- "referenceNo": '61G33IGAPTVZPY5',
80
- "referenceType": 'CU'
79
+ "reference_no": '61G33IGAPTVZPY5',
80
+ "reference_type": 'CU'
81
81
  }
82
82
  ],
83
83
  "parties": {
84
84
  "consignor": {
85
- "issuerCode": 'Z12',
86
- "partyIdentification": {
87
- "partyId": '1111111111',
88
- "partyIdType": '160'
85
+ "issuer_code": 'Z12',
86
+ "party_identification": {
87
+ "party_id": '1111111111',
88
+ "party_id_type": '160'
89
89
  },
90
90
  "party": {
91
- "nameIdentification": {
91
+ "name_identification": {
92
92
  "name": 'CONSIGNOR'
93
93
  },
94
94
  "address": {
95
95
  "streets": [
96
96
  'Terminalvägen 14'
97
97
  ],
98
- "postalCode": '17173',
98
+ "postal_code": '17173',
99
99
  "city": 'solna',
100
- "countryCode": 'SE'
100
+ "country_code": 'SE'
101
101
  },
102
102
  "contact": {
103
- "contactName": 'Consignor',
104
- "emailAddress": 'Consignor@me.com',
105
- "phoneNo": '+46071111111',
106
- "smsNo": '+46071111111'
103
+ "contact_name": 'Consignor',
104
+ "email_address": 'Consignor@me.com',
105
+ "phone_no": '+46071111111',
106
+ "sms_no": '+46071111111'
107
107
  }
108
108
  }
109
109
  },
110
110
  "consignee": {
111
111
  "party": {
112
- "nameIdentification": {
112
+ "name_identification": {
113
113
  "name": 'Consignee'
114
114
  },
115
115
  "address": {
116
116
  "streets": [
117
117
  'Östermalmsgatan 87D'
118
118
  ],
119
- "postalCode": '11459',
119
+ "postal_code": '11459',
120
120
  "city": 'STOCKHOLM',
121
- "countryCode": 'SE'
121
+ "country_code": 'SE'
122
122
  },
123
123
  "contact": {
124
- "contactName": 'Consignee',
125
- "emailAddress": 'Consignee@me.com',
126
- "phoneNo": '+46071111111',
127
- "smsNo": '+46071111111'
124
+ "contact_name": 'Consignee',
125
+ "email_address": 'Consignee@me.com',
126
+ "phone_no": '+46071111111',
127
+ "sms_no": '+46071111111'
128
128
  }
129
129
  }
130
130
  }
131
131
  },
132
- "goodsItem": [
132
+ "goods_item": [
133
133
  {
134
134
  "marking": 'Description of the commodities',
135
- "goodsDescription": 'goodsDescription',
136
- "packageTypeCode": 'PC',
135
+ "goods_description": 'goodsDescription',
136
+ "package_type_code": 'PC',
137
137
  "items": [
138
138
  {
139
- "itemIdentification": {
140
- "itemId": '0'
139
+ "item_identification": {
140
+ "item_id": '0'
141
141
  }
142
142
  }
143
143
  ]
@@ -42,6 +42,11 @@ module PostNordAPI
42
42
  end
43
43
  end
44
44
 
45
+ def parse_params(params)
46
+ # Convert { snake_case_key: value } to { snakeCaseKey: value }
47
+ params.deep_transform_keys { |key| key.to_s.camelize(:lower) }
48
+ end
49
+
45
50
  private
46
51
 
47
52
  def extract_error_message(body)
@@ -3,11 +3,11 @@
3
3
  module PostNordAPI
4
4
  class ShipmentResource < BaseResource
5
5
  def create_return_label(params)
6
- response = post_request("shipment/v3/returns/edi/labels/zpl", body: params)
6
+ response = post_request('shipment/v3/returns/edi/labels/zpl', body: parse_params(params))
7
7
  Booking.new(response.body)
8
8
  end
9
9
 
10
- def track(tracking_number, locale: "en")
10
+ def track(tracking_number, locale: 'en')
11
11
  response = get_request("shipment/v5/trackandtrace/findByIdentifier.json?id=#{tracking_number}&locale=#{locale}")
12
12
  Tracking.new(response.body)
13
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostNordAPI
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: post_nord_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linh