czech_post_b2b_client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +40 -0
- data/CHANGELOG.md +14 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +281 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/certs/postsignum_qca4_root.pem +41 -0
- data/certs/postsignum_vca5_sub.pem +44 -0
- data/doc/CzechPostB2bClient.html +479 -0
- data/doc/CzechPostB2bClient/B2BErrors.html +242 -0
- data/doc/CzechPostB2bClient/B2BErrors/BadRequestError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/BaseError.html +376 -0
- data/doc/CzechPostB2bClient/B2BErrors/CustomerRequestsCountOverflowError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/InternalB2BServerError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/InternalBackendServerError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/InternalDataPersistenceServerError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/ProcessingUnfinishedYetError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/ServiceBusyError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/UnauthorizedContractAccessError.html +145 -0
- data/doc/CzechPostB2bClient/B2BErrors/UnauthorizedRoleAccessError.html +145 -0
- data/doc/CzechPostB2bClient/Configuration.html +1005 -0
- data/doc/CzechPostB2bClient/Error.html +128 -0
- data/doc/CzechPostB2bClient/PrintingTemplates.html +199 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AddressData3x8.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel.html +117 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/Blank.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/Blank4OnPage.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/BlankLandscape.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage.html +115 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage/EMS.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage/EMS2x4.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage/Standard.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage/Standard4OnPage.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage/Valuable.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/ForeignPackage/Valuable4OnPage.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/Simple.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/AdressLabel/SimpleWithCODVoucherA.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/Base.html +279 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/CODVoucherA.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/CODVoucherA3OnPage.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/CODVoucherC.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/CODVoucherForCSOB.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/CustomDeclarationCN22.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/CustomDeclarationCN23.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/DeliveryTicket.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/Envelope.html +115 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/Envelope/EnvelopeB4.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/Envelope/EnvelopeC5.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/Envelope/EnvelopeC6.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/Envelope/EnvelopeDL.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/HarmonizedLabel.html +141 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/HarmonizedLabel4OnPage.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/IntegratedDocument.html +129 -0
- data/doc/CzechPostB2bClient/PrintingTemplates/RRLabels3x8.html +129 -0
- data/doc/CzechPostB2bClient/RequestBuilders.html +117 -0
- data/doc/CzechPostB2bClient/RequestBuilders/BaseBuilder.html +396 -0
- data/doc/CzechPostB2bClient/RequestBuilders/GetParcelStateBuilder.html +329 -0
- data/doc/CzechPostB2bClient/RequestBuilders/GetParcelsPrintingBuilder.html +470 -0
- data/doc/CzechPostB2bClient/RequestBuilders/GetResultParcelsBuilder.html +329 -0
- data/doc/CzechPostB2bClient/RequestBuilders/GetStatsBuilder.html +403 -0
- data/doc/CzechPostB2bClient/RequestBuilders/SendParcelsBuilder.html +403 -0
- data/doc/CzechPostB2bClient/ResponseCodes.html +242 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddressAllowedForBalikovnaOnly.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddressIsNotValidForSubject.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddressNeedsPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddressSuitableForLocalDelivery.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddressValidOnlyForNaPostu.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddressValidOnlyForNaPostuDuplicate.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AddresseeCityRequired.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/AlreadyAssignedOrderNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadAddressee.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadCODAmount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadFormatReturnNumberDays.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadHeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadLength.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadPrefix.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadPrefixForAddress.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadPrice.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadVariableSymbol.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadWeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BadWidth.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BaseCode.html +550 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BatchClosed.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BatchInvalid.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/BatchUnfinished.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/CODAmountOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/CODAmountTooBig.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/CanceledOrderNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/CustomGoodQuantityOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/CustomerIDNotInAccordanceWithParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/DensityOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/DuplicateDuplicateParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/DuplicateParcel.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/DuplicateParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/DuplicitParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/FullSequence.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/FullSequenceDuplicate.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/IllegalCombinationOfServices.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddRequiredService75.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddService1A.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddService1B.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddService1D.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddService9.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddressWasModified.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoAddresseeToLong.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelCustCardNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelCustCardNumberAddresseeDocument.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelHeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelLength.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelMobilePhoneOrEmailAddresseeDocument.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelPalettsNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelPersonalIdentificationNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1AB.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1ABForService40.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1AForPostCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1AForService40.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1AWith1B.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1B.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1BAddService1A.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1BForPostCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1BWith1A.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1D.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1E.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService1V.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService25.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService27.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService29.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService30.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService31.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService34.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService34InvalidPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService45.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService45InvalidPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService46.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService47.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService5B.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService5BAnd5C.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService5BAnd5D.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService5C.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService5CAnd5D.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelService5D.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelVSVoucher.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCancelWidth.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoCityChanged.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInexactAddress.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidAccount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidBankCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidBirthDay.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidCODAmount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidCategoryCustomDecalaration.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidMobilePhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidPrefixAccount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidPrice.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidSpecificSymbol.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidTelephoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoInvalidWeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoMissingPartCityServiceDeliveryOnSundayOrHolidayMayNotBeRealized.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoPriceIsNotNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoPriceIsTooBig.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoService29And47.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InfoSpecialPackagingRequest.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InternalApplicationError.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressAddresseeDocumentForParcelType.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressAddresseeDocumentObjectNotFound.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressAddresseeDocumentWrongCity.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressForBalikovna.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressForBigPackage.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressForCODAmountOver20000.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressForParcelType.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAddressee.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAmount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAmountCurrency.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidAmountType.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCODAmount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCODCurrency.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCODCurrencyAccordance.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCategoryCustomDecalaration.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidContentCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCurrencyCustomDecalaration.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCustomGoodNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCustomerCardNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidCustomerId.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidDensity.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidHeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidHsCodeCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidIsoCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidIsoCustomGoodFormat.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidLength.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidLocation.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidMRNCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidMRNCodeControl.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidNumberClosure.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidOrderNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidParcelBarcode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidParcelBarcodeDuplicate.html +145 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidParcelCodeControl.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidParcelResponseCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidParcelTypeForID.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPartnerCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPayday.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPostCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPrefixAccordance.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPrefixCombination.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPrefixForDimensionsAndFragile.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPrice.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPriceCurrency.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPriceCurrencyAccordance.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidPriceCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidQuantityCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidResponsibleConsignmentNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidReturnNumberDays.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidService18.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidService19.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidServiceCombination.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidServicesForDimensions.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidSignNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidSubisoCountry.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidTareWeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidTiming.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidTransmissionDate.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidTypePrefix.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidUseOfService36.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidUseOfService37.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidUseOfService38.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidWeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidWeightCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidWeightCustomGoodSummary.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidWeightForService11.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidWidth.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidZPROOrderNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidZPROOrderNumberFormat.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/InvalidostCodeOrCity.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MIssingParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingAddressee.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingAddresseeCity.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingAddresseeStreet.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingAddresseeZipCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingCODAmount.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingCODAmountType.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingCategoryCustomDecalaration.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingCompanyName.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingContentCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingCurrencyCustomDeclaration.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingHandlingInstructions.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingHeight.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingHsCodeCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingIsoCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingLength.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingPalettsNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingParcelCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingParcelCustomGoods.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingPrefix.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingPrice.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingPriceCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingQuantityCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredAddresseeDocument.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredAddresseeDocumentDuplicate.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredAddresseeEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredFirstNameAddresseeDocument.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredMRNCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredMobileNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredMobileNumberOrEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredParcelCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredPayday.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredPhoneNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredPhoneNumberOrEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredPhoneNumberOrWhat.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredPrice.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService10.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService1AB.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService1X.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService2X.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService3X.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService3XTrinity.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService4.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService4X.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredService4x.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredVoucherPrice.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingRequiredZPROOrderNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingReturnInstructions.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingReturnNumberDays.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingSenderEmail.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingSizeCategory.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingSurname.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingVariableSymbol.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingVariableSymbolDuplicate.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingWeightCustomGood.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/MissingWidth.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/NfoCancelService9.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/NoContractService41.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/NoContractServiceReturnReceipt.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/NotExistingOrderNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/Ok.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/OverenoVecerniDorucovani.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/PalettsNumberOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/ParcelCodeNotAllowed.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/ParcelCodeNotInAssignedRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/ParcelDoesNotMeetTheRequirementsForm.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/PriceAndCODAmountTooBig.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/PriceOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/PriceTooBig.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/PriceTooLow.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/ResponsibleConsignmentNumberCannotBeImported.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/ResponsibleConsignmentNumberOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/ServicesCombinationNotAllowed.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/TransmissionAlreadyClosed.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/TransmissionNotExists.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/TransmissionOpened.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/TransmissionUnfinished.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/UnauthorizedAccess.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/UnknownAddresseeCity.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/UnknownAddresseePostCode.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/UnknownPrefix.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/VariableSymbolIsNotNumber.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/WeightCustomGoodOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/WeightIsOutOfRange.html +134 -0
- data/doc/CzechPostB2bClient/ResponseCodes/WeightIsOutOfRangeDuplicate.html +134 -0
- data/doc/CzechPostB2bClient/ResponseParsers.html +117 -0
- data/doc/CzechPostB2bClient/ResponseParsers/BaseParser.html +283 -0
- data/doc/CzechPostB2bClient/ResponseParsers/GetParcelStateParser.html +533 -0
- data/doc/CzechPostB2bClient/ResponseParsers/GetParcelsPrintingParser.html +463 -0
- data/doc/CzechPostB2bClient/ResponseParsers/GetResultParcelsParser.html +625 -0
- data/doc/CzechPostB2bClient/ResponseParsers/GetStatsParser.html +347 -0
- data/doc/CzechPostB2bClient/ResponseParsers/SendParcelsParser.html +231 -0
- data/doc/CzechPostB2bClient/Services.html +117 -0
- data/doc/CzechPostB2bClient/Services/AddressSheetsGenerator.html +451 -0
- data/doc/CzechPostB2bClient/Services/ApiCaller.html +307 -0
- data/doc/CzechPostB2bClient/Services/Communicator.html +220 -0
- data/doc/CzechPostB2bClient/Services/DeliveringInspector.html +324 -0
- data/doc/CzechPostB2bClient/Services/Orchestrator.html +143 -0
- data/doc/CzechPostB2bClient/Services/ParcelsSendProcessUpdater.html +377 -0
- data/doc/CzechPostB2bClient/Services/ParcelsSender.html +402 -0
- data/doc/CzechPostB2bClient/Services/ParcelsSubmissionCloser.html +337 -0
- data/doc/CzechPostB2bClient/Services/TimePeriodStatisticator.html +398 -0
- data/doc/SteppedService.html +224 -0
- data/doc/SteppedService/Base.html +706 -0
- data/doc/SteppedService/Errors.html +365 -0
- data/doc/_index.html +2607 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +357 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +357 -0
- data/doc/js/app.js +303 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +923 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/czech_post_b2b_client.rb +37 -0
- data/lib/czech_post_b2b_client/b2b_errors.rb +105 -0
- data/lib/czech_post_b2b_client/configuration.rb +34 -0
- data/lib/czech_post_b2b_client/printing_templates.rb +166 -0
- data/lib/czech_post_b2b_client/request_builders.rb +8 -0
- data/lib/czech_post_b2b_client/request_builders/base_builder.rb +90 -0
- data/lib/czech_post_b2b_client/request_builders/get_parcel_state_builder.rb +44 -0
- data/lib/czech_post_b2b_client/request_builders/get_parcels_printing_builder.rb +79 -0
- data/lib/czech_post_b2b_client/request_builders/get_result_parcels_builder.rb +28 -0
- data/lib/czech_post_b2b_client/request_builders/get_stats_builder.rb +30 -0
- data/lib/czech_post_b2b_client/request_builders/send_parcels_builder.rb +294 -0
- data/lib/czech_post_b2b_client/response_codes.rb +1900 -0
- data/lib/czech_post_b2b_client/response_parsers.rb +8 -0
- data/lib/czech_post_b2b_client/response_parsers/base_parser.rb +95 -0
- data/lib/czech_post_b2b_client/response_parsers/get_parcel_state_parser.rb +54 -0
- data/lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb +42 -0
- data/lib/czech_post_b2b_client/response_parsers/get_result_parcels_parser.rb +56 -0
- data/lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb +27 -0
- data/lib/czech_post_b2b_client/response_parsers/send_parcels_parser.rb +13 -0
- data/lib/czech_post_b2b_client/services.rb +10 -0
- data/lib/czech_post_b2b_client/services/address_sheets_generator.rb +55 -0
- data/lib/czech_post_b2b_client/services/api_caller.rb +115 -0
- data/lib/czech_post_b2b_client/services/communicator.rb +28 -0
- data/lib/czech_post_b2b_client/services/delivering_inspector.rb +50 -0
- data/lib/czech_post_b2b_client/services/orchestrator.rb +27 -0
- data/lib/czech_post_b2b_client/services/parcels_send_process_updater.rb +71 -0
- data/lib/czech_post_b2b_client/services/parcels_sender.rb +53 -0
- data/lib/czech_post_b2b_client/services/parcels_submission_closer.rb +23 -0
- data/lib/czech_post_b2b_client/services/time_period_statisticator.rb +44 -0
- data/lib/czech_post_b2b_client/version.rb +5 -0
- data/lib/stepped_service.rb +4 -0
- data/lib/stepped_service/base.rb +139 -0
- data/lib/stepped_service/errors.rb +29 -0
- metadata +571 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'czech_post_b2b_client/response_parsers/base_parser'
|
4
|
+
require 'czech_post_b2b_client/response_parsers/get_stats_parser'
|
5
|
+
require 'czech_post_b2b_client/response_parsers/get_parcels_printing_parser'
|
6
|
+
require 'czech_post_b2b_client/response_parsers/get_parcel_state_parser'
|
7
|
+
require 'czech_post_b2b_client/response_parsers/get_result_parcels_parser'
|
8
|
+
require 'czech_post_b2b_client/response_parsers/send_parcels_parser'
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ox'
|
4
|
+
|
5
|
+
module CzechPostB2bClient
|
6
|
+
module ResponseParsers
|
7
|
+
class BaseParser < SteppedService::Base
|
8
|
+
def initialize(xml:)
|
9
|
+
@response_xml = xml
|
10
|
+
end
|
11
|
+
|
12
|
+
def steps
|
13
|
+
%i[parse_xml safely_build_result]
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_accessor :response_xml, :response_hash
|
19
|
+
|
20
|
+
def parse_xml
|
21
|
+
@response_hash = Ox.load(response_xml,
|
22
|
+
strip_namespace: true,
|
23
|
+
symbolize_keys: false,
|
24
|
+
mode: :hash_no_attrs)
|
25
|
+
rescue Ox::ParseError => error
|
26
|
+
handle_parsing_error(error)
|
27
|
+
end
|
28
|
+
|
29
|
+
def safely_build_result
|
30
|
+
build_result
|
31
|
+
rescue NoMethodError => error # NoMethodError: undefined method `dig' for nil:NilClass
|
32
|
+
handle_result_building_error(error)
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_result
|
36
|
+
@result = {
|
37
|
+
request: { created_at: request_data.time_stamp,
|
38
|
+
contract_id: request_data.id_contract,
|
39
|
+
request_id: request_data.id_ext_transaction },
|
40
|
+
response: { created_at: Time.parse(response_header.dig('timeStamp')) }
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def response_service_data
|
45
|
+
b2b_response_hash.dig('serviceData')
|
46
|
+
end
|
47
|
+
|
48
|
+
def response_header
|
49
|
+
b2b_response_hash.dig('header')
|
50
|
+
end
|
51
|
+
|
52
|
+
def response_root_node
|
53
|
+
return response_service_data.dig(response_root_node_name) if response_service_data.keys.include?(response_root_node_name)
|
54
|
+
|
55
|
+
errors.add(:xml, "Cannot find `#{response_root_node_name}` in `serviceData` node.")
|
56
|
+
fail_on_structure_parsing
|
57
|
+
end
|
58
|
+
|
59
|
+
def b2b_response_hash
|
60
|
+
response_hash.dig('b2bSyncResponse') || response_hash.dig('b2bASyncResponse')
|
61
|
+
end
|
62
|
+
|
63
|
+
def request_data
|
64
|
+
b2b_request_hash = response_header.dig('b2bRequestHeader')
|
65
|
+
OpenStruct.new(id_ext_transaction: b2b_request_hash.dig('idExtTransaction').to_s,
|
66
|
+
time_stamp: Time.parse(b2b_request_hash.dig('timeStamp')),
|
67
|
+
id_contract: b2b_request_hash.dig('idContract').to_s)
|
68
|
+
end
|
69
|
+
|
70
|
+
def state_hash_from(hash)
|
71
|
+
state_hash = hash || { 'responseCode' => '999', 'responseText' => 'Unknown' }
|
72
|
+
state_hash = state_hash.first if state_hash.is_a?(Array) # more <doParcelStateResponse> elements
|
73
|
+
|
74
|
+
{ code: state_hash['responseCode'].to_i, text: state_hash['responseText'].to_s}
|
75
|
+
end
|
76
|
+
|
77
|
+
def handle_parsing_error(error)
|
78
|
+
@result = { parser_error: error.message, xml: response_xml }
|
79
|
+
errors.add(:xml, "XML can not be parsed! Is it valid XML? #{error.class} > #{error.message}")
|
80
|
+
fail!
|
81
|
+
end
|
82
|
+
|
83
|
+
def handle_result_building_error(error)
|
84
|
+
@result = { result_builder_error: error.message + ' at line: ' + error.backtrace.first,
|
85
|
+
response_hash: response_hash }
|
86
|
+
fail_on_structure_parsing
|
87
|
+
end
|
88
|
+
|
89
|
+
def fail_on_structure_parsing
|
90
|
+
errors.add(:xml, 'Parsed XML can not be converted to result hash. Is it correct response for this parser?')
|
91
|
+
fail!
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CzechPostB2bClient
|
4
|
+
module ResponseParsers
|
5
|
+
class GetParcelStateParser < BaseParser
|
6
|
+
def build_result
|
7
|
+
super
|
8
|
+
@result[:parcels] = parcels_data_hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def parcels_data_hash
|
12
|
+
response_parcel_hashes.each_with_object({}) do |rp_hash, result|
|
13
|
+
result[rp_hash['idParcel']] = parcel_data_from(rp_hash)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def response_root_node_name
|
18
|
+
'getParcelStateResponse'
|
19
|
+
end
|
20
|
+
|
21
|
+
def response_parcel_hashes
|
22
|
+
return [] if response_root_node.nil?
|
23
|
+
|
24
|
+
[response_root_node.dig('parcel')].flatten.compact # to always get array of hash(es)
|
25
|
+
end
|
26
|
+
|
27
|
+
def parcel_data_from(rp_hash)
|
28
|
+
{
|
29
|
+
parcel_type: rp_hash['parcelType'].to_s,
|
30
|
+
weight_in_kg: rp_hash['weight'].nil? ? nil : rp_hash['weight'].to_f, # hopefully it is in KG
|
31
|
+
cash_on_delivery: { amount: (rp_hash['amount'] || 0).to_f, currency_iso_code: rp_hash['currency'].to_s },
|
32
|
+
pieces: (rp_hash['quantityParcel'] || 1).to_i,
|
33
|
+
deposited_until: rp_hash['depositTo'].nil? ? nil : Date.parse(rp_hash['depositTo']),
|
34
|
+
deposited_for_days: rp_hash['timeDeposit'].nil? ? nil : rp_hash['timeDeposit'].to_i,
|
35
|
+
country_of_origin: rp_hash['countryOfOrigin'].to_s,
|
36
|
+
country_of_destination: rp_hash['countryOfDestination'].to_s,
|
37
|
+
states: states_array_from(rp_hash)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def states_array_from(rp_hash)
|
42
|
+
rp_states = [rp_hash.dig('states', 'state')].flatten.compact # to always get (empty?) array of hash(es)
|
43
|
+
|
44
|
+
rp_states.collect do |rp_state_hash|
|
45
|
+
{ id: rp_state_hash['id'].to_s,
|
46
|
+
date: Date.parse(rp_state_hash['date']),
|
47
|
+
text: rp_state_hash['text'],
|
48
|
+
post_code: rp_state_hash['postCode'],
|
49
|
+
post_name: rp_state_hash['name'] }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "base64"
|
3
|
+
|
4
|
+
module CzechPostB2bClient
|
5
|
+
module ResponseParsers
|
6
|
+
class GetParcelsPrintingParser < BaseParser
|
7
|
+
def build_result
|
8
|
+
super
|
9
|
+
@result[:response][:state] = state_hash_from(printing_response_header_result.dig('doPrintingStateResponse'))
|
10
|
+
@result[:printings] = { options: options_hash,
|
11
|
+
pdf_content: pdf_content }
|
12
|
+
end
|
13
|
+
|
14
|
+
def options_hash
|
15
|
+
options_response = printing_response_header_result.dig('doPrintingHeader')
|
16
|
+
{
|
17
|
+
customer_id: options_response.dig('customerID'),
|
18
|
+
contract_number: options_response.dig('contractNumber'),
|
19
|
+
template_id: options_response.dig('idForm').to_i,
|
20
|
+
margin_in_mm: { top: options_response.dig('shiftVertical').to_i,
|
21
|
+
left: options_response.dig('shiftHorizontal').to_i },
|
22
|
+
position_order: options_response.dig('position').to_i
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def pdf_content
|
27
|
+
pdf_content_encoded = response_root_node.dig('doPrintingDataResult', 'file')
|
28
|
+
return nil if pdf_content_encoded.nil?
|
29
|
+
|
30
|
+
::Base64.decode64(pdf_content_encoded)
|
31
|
+
end
|
32
|
+
|
33
|
+
def response_root_node_name
|
34
|
+
'getParcelsPrintingResponse'
|
35
|
+
end
|
36
|
+
|
37
|
+
def printing_response_header_result
|
38
|
+
response_root_node.dig('doPrintingHeaderResult')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CzechPostB2bClient
|
4
|
+
module ResponseParsers
|
5
|
+
class GetResultParcelsParser < BaseParser
|
6
|
+
def build_result
|
7
|
+
super
|
8
|
+
@result[:response][:state] = state_hash_from(response_state_response)
|
9
|
+
@result[:parcels] = parcels_data_hash
|
10
|
+
end
|
11
|
+
|
12
|
+
def parcels_data_hash
|
13
|
+
response_parcel_hashes.each_with_object({}) do |rp_hash, result|
|
14
|
+
parcel_id = parcel_parcel_id_from(rp_hash)
|
15
|
+
result[parcel_id] = updated_result_value_for(result[parcel_id], rp_hash)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def response_root_node_name
|
20
|
+
'getResultParcelsResponse'
|
21
|
+
end
|
22
|
+
|
23
|
+
def response_state_response
|
24
|
+
response_root_node.dig('doParcelHeaderResult', 'doParcelStateResponse')
|
25
|
+
end
|
26
|
+
|
27
|
+
def response_parcel_hashes
|
28
|
+
[response_root_node.dig('doParcelParamResult')].flatten.compact # to always get array of hash(es)
|
29
|
+
end
|
30
|
+
|
31
|
+
def parcel_parcel_id_from(rp_hash)
|
32
|
+
rp_hash['recordNumber'].to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def parcel_data_from(rp_hash)
|
36
|
+
{ parcel_code: rp_hash['parcelCode'],
|
37
|
+
states: [state_hash_from(rp_hash.dig('doParcelStateResponse'))] }
|
38
|
+
end
|
39
|
+
|
40
|
+
def updated_result_value_for(value, parcel_params_result_hash)
|
41
|
+
pd_hash=parcel_data_from(parcel_params_result_hash)
|
42
|
+
|
43
|
+
return pd_hash if value.nil?
|
44
|
+
|
45
|
+
# more doParcelParamsResult nodes for one parcel_id => probably errors
|
46
|
+
old_p_code = value[:parcel_code]
|
47
|
+
new_p_code = pd_hash[:parcel_code]
|
48
|
+
|
49
|
+
value[:states] = (value[:states] + pd_hash[:states]).sort { |a, b| a[:code] <=> b[:code] }
|
50
|
+
raise "Two different parcel_codes [#{old_p_code}, #{new_p_code}] for parcel_id:'#{parcel_id}'" if old_p_code != new_p_code
|
51
|
+
|
52
|
+
value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CzechPostB2bClient
|
4
|
+
module ResponseParsers
|
5
|
+
class GetStatsParser < BaseParser
|
6
|
+
def build_result
|
7
|
+
super
|
8
|
+
@result[:imports] = { requested: imports.all,
|
9
|
+
with_errors: imports.err,
|
10
|
+
successful: imports.ok,
|
11
|
+
imported_parcels: imports.parcels }
|
12
|
+
end
|
13
|
+
|
14
|
+
def imports
|
15
|
+
imports_hash = response_root_node
|
16
|
+
OpenStruct.new(all: imports_hash.dig('importAll').to_i,
|
17
|
+
err: imports_hash.dig('importErr').to_i,
|
18
|
+
ok: imports_hash.dig('importOk').to_i,
|
19
|
+
parcels: imports_hash.dig('parcels').to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
def response_root_node_name
|
23
|
+
'getStatsResponse'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CzechPostB2bClient
|
4
|
+
module ResponseParsers
|
5
|
+
class SendParcelsParser < BaseParser
|
6
|
+
def build_result
|
7
|
+
super
|
8
|
+
@result[:async_result] = { transaction_id: response_header.dig('idTransaction'),
|
9
|
+
processing_end_expected_at: Time.parse(response_header.dig('timeStampProcessing')) } # it is NOT CORRECT! They return CET time value with UTC timezone
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'czech_post_b2b_client/services/orchestrator'
|
3
|
+
require 'czech_post_b2b_client/services/communicator'
|
4
|
+
require 'czech_post_b2b_client/services/api_caller'
|
5
|
+
require 'czech_post_b2b_client/services/parcels_sender'
|
6
|
+
require 'czech_post_b2b_client/services/parcels_send_process_updater'
|
7
|
+
require 'czech_post_b2b_client/services/address_sheets_generator'
|
8
|
+
require 'czech_post_b2b_client/services/parcels_submission_closer'
|
9
|
+
require 'czech_post_b2b_client/services/delivering_inspector'
|
10
|
+
require 'czech_post_b2b_client/services/time_period_statisticator'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CzechPostB2bClient
|
4
|
+
module Services
|
5
|
+
class AddressSheetsGenerator < CzechPostB2bClient::Services::Communicator
|
6
|
+
attr_reader :parcel_codes, :options
|
7
|
+
|
8
|
+
def initialize(parcel_codes:, options: {})
|
9
|
+
@parcel_codes = parcel_codes
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def steps
|
14
|
+
super + %i[check_for_state_errors]
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def request_builder_args
|
20
|
+
{ parcel_codes: parcel_codes, options: options }
|
21
|
+
end
|
22
|
+
|
23
|
+
def request_builder_class
|
24
|
+
CzechPostB2bClient::RequestBuilders::GetParcelsPrintingBuilder
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_caller_class
|
28
|
+
CzechPostB2bClient::Services::ApiCaller
|
29
|
+
end
|
30
|
+
|
31
|
+
def response_parser_class
|
32
|
+
CzechPostB2bClient::ResponseParsers::GetParcelsPrintingParser
|
33
|
+
end
|
34
|
+
|
35
|
+
def endpoint_path
|
36
|
+
'/getParcelsPrinting'
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_result_from(response_hash)
|
40
|
+
OpenStruct.new(pdf_content: response_hash.dig(:printings, :pdf_content),
|
41
|
+
state_text: response_hash.dig(:response, :state, :text),
|
42
|
+
state_code: response_hash.dig(:response, :state, :code))
|
43
|
+
end
|
44
|
+
|
45
|
+
def check_for_state_errors
|
46
|
+
return if result.state_code == CzechPostB2bClient::ResponseCodes::Ok.code
|
47
|
+
|
48
|
+
r_code = CzechPostB2bClient::ResponseCodes.new_by_code(result.state_code)
|
49
|
+
errors.add(:response_state, r_code.to_s)
|
50
|
+
|
51
|
+
fail! unless r_code.info?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'openssl'
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
module CzechPostB2bClient
|
7
|
+
module Services
|
8
|
+
class ApiCaller < SteppedService::Base
|
9
|
+
KNOWN_CONNECTION_ERRORS = [
|
10
|
+
Timeout::Error,
|
11
|
+
Errno::EINVAL,
|
12
|
+
Errno::ECONNRESET,
|
13
|
+
EOFError,
|
14
|
+
SocketError,
|
15
|
+
Net::ReadTimeout,
|
16
|
+
Net::HTTPBadResponse,
|
17
|
+
Net::HTTPHeaderSyntaxError,
|
18
|
+
Net::ProtocolError
|
19
|
+
].freeze
|
20
|
+
|
21
|
+
def initialize(endpoint_path:, xml:)
|
22
|
+
@endpoint_path = endpoint_path
|
23
|
+
@request_xml = xml
|
24
|
+
end
|
25
|
+
|
26
|
+
def steps
|
27
|
+
%i[call_api handle_response]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_accessor :request_xml, :response, :endpoint_path
|
33
|
+
|
34
|
+
def call_api
|
35
|
+
request = Net::HTTP::Post.new service_uri.request_uri, headers
|
36
|
+
request.body = request_xml
|
37
|
+
CzechPostB2bClient.logger.debug("CzechPost B2B REQUEST: #{request} to #{service_uri.request_uri} with body:\n#{request.body}")
|
38
|
+
begin
|
39
|
+
self.response = https_conn.request(request)
|
40
|
+
rescue *KNOWN_CONNECTION_ERRORS => e
|
41
|
+
handle_connection_error(e)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def handle_response
|
46
|
+
CzechPostB2bClient.logger.debug("CzechPost B2B RESPONSE: #{response} with body:\n#{response.body}")
|
47
|
+
|
48
|
+
@result = ::OpenStruct.new(code: response.code.to_i, xml: response.body)
|
49
|
+
return unless b2b_error?
|
50
|
+
|
51
|
+
errors.add(:b2b, b2b_error_text)
|
52
|
+
fail!
|
53
|
+
end
|
54
|
+
|
55
|
+
def https_conn
|
56
|
+
@https_conn ||= Net::HTTP.start(service_uri.host, service_uri.port, connection_options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def service_uri
|
60
|
+
@service_uri ||= URI.parse(configuration.b2b_api_base_uri + endpoint_path)
|
61
|
+
end
|
62
|
+
|
63
|
+
def headers
|
64
|
+
{ 'Content-Type': 'text/xml' }
|
65
|
+
end
|
66
|
+
|
67
|
+
def connection_options
|
68
|
+
{
|
69
|
+
use_ssl: true,
|
70
|
+
verify_mode: OpenSSL::SSL::VERIFY_PEER,
|
71
|
+
keep_alive_timeout: 30,
|
72
|
+
cert: OpenSSL::X509::Certificate.new(File.read(configuration.certificate_path)),
|
73
|
+
# cert_password: configuration.certificate_password,
|
74
|
+
key: OpenSSL::PKey::RSA.new(File.read(configuration.private_key_path), configuration.private_key_password),
|
75
|
+
cert_store: post_signum_ca_store
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def configuration
|
80
|
+
CzechPostB2bClient.configuration
|
81
|
+
end
|
82
|
+
|
83
|
+
def post_signum_ca_store
|
84
|
+
store = OpenSSL::X509::Store.new
|
85
|
+
store.set_default_paths # Optional method that will auto-include the system CAs.
|
86
|
+
|
87
|
+
# store.add_cert(OpenSSL::X509::Certificate.new(File.read("/path/to/ca2.crt")))
|
88
|
+
store.add_file(File.join(CzechPostB2bClient.certs_path, 'postsignum_qca4_root.pem'))
|
89
|
+
store.add_file(File.join(CzechPostB2bClient.certs_path, 'postsignum_vca5_sub.pem'))
|
90
|
+
store
|
91
|
+
end
|
92
|
+
|
93
|
+
def b2b_error?
|
94
|
+
result&.xml&.include?('B2BFaultMessage')
|
95
|
+
end
|
96
|
+
|
97
|
+
def b2b_error_text
|
98
|
+
error_match = result.xml.match(%r{<(?:\w+\:)?errorCode>(\d+)</(?:\w+\:)?errorCode>}) # errorCode tag with stripped out namespace
|
99
|
+
return 'error code not found in XML' unless error_match
|
100
|
+
|
101
|
+
error_code = error_match[1].to_i
|
102
|
+
error = CzechPostB2bClient::B2BErrors.new_by_code(error_code)
|
103
|
+
return "error code [#{error_code}] is unknown" unless error
|
104
|
+
|
105
|
+
error.message
|
106
|
+
end
|
107
|
+
|
108
|
+
def handle_connection_error(error)
|
109
|
+
@result = OpenStruct.new(code: 500, xml: '')
|
110
|
+
errors.add(:connection, "#{error.class} > #{service_uri} - #{error}")
|
111
|
+
fail!
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|