locked
conversion suggestion RRS feed

  • Question

  • User-1104215994 posted

    Hi,

    Client (one of a shopping chain terminal) sends <g class="gr_ gr_709 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" id="709" data-gr-id="709">request</g> to my web API. In this request there is a <g class="gr_ gr_78 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="78" data-gr-id="78">productCode</g>, <g class="gr_ gr_89 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="89" data-gr-id="89">lets</g> say 123456. I am getting this request and send it to another web API (X). My API is like a middleware. Gets the response from web API (X) and <g class="gr_ gr_456 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="456" data-gr-id="456">forward</g> it to the client. So far so good. Now there is another <g class="gr_ gr_583 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="583" data-gr-id="583">productCode</g>, <g class="gr_ gr_616 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="616" data-gr-id="616">lets</g> say ABC1. Shopping chain terminal says I can not send ABC123. I can send 6 <g class="gr_ gr_1184 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="1184" data-gr-id="1184">digit</g> numeric <g class="gr_ gr_1181 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="1181" data-gr-id="1181">productCode</g>. So I need to convert <g class="gr_ gr_1279 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="1279" data-gr-id="1279">productCodes</g>. Should I create a DB table and keep the <g class="gr_ gr_1764 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="1764" data-gr-id="1764">productCodes</g> in there? What are the other choices? Would you please guide me?

    Thanks in advance.

    Wednesday, October 2, 2019 10:54 AM

Answers

  • User753101303 posted

    Ok so then it seems you have no other way than generating your own id for each alphanumerical generated by this service to serve that your client and it seems to make sense to keep that in a db, you don't have one already or which problem do you anticipate?

    Or maybe the ABC part has some special meaning ? It's not your own customer code in the 3rd party system for example. If fixed it could be just dropped...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 2, 2019 11:30 AM
  • User475983607 posted

    It seems to me that you've designed a product code alias where the client knows nothing about the 3rd party product code.  Now your asking the community to come up with a design for code we know nothing about.

    cenk1536

    I am not sure but going one more time to the database makes me think twice.

    Logically the alias and product code must be stored in non-volatile location like a database.  If you are concerned about DB calls,  cache the product code to alias mapping.  Similar to your previous post related to device ID request throttling.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 2, 2019 11:53 AM

All replies

  • User753101303 posted

    We would first need to better understand the purpose of this "translation". You mean the product code posted to your API is not the same used by the underlying service you are using ? And so you need to translate them when going from one side to the other side ? Where do you find the information needed to map those codes ?

    Or that by design your existting app generates alphanum codes when your client can use only numerical codes ??? Why would you have to send ABC123 rather than a numeric code ? You get this id from the 3rd party service you are using ???

    Not sure about the exact domain but I would expect to use rather some kind of https://en.wikipedia.org/wiki/Universal_Product_Code

    Wednesday, October 2, 2019 11:07 AM
  • User-1104215994 posted

    Thanks for your fast reply <g class="gr_ gr_17 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="17" data-gr-id="17">PatriceSc</g>.

    <g class="gr_ gr_25 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="25" data-gr-id="25">You</g> mean the product code posted to your API is not the same used by the underlying service you are <g class="gr_ gr_26 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="26" data-gr-id="26">using ?</g> Yes, they are NOT the same. The service that I am calling with my API is the source of the product codes.

    And so you need to translate them when going from one side to the other <g class="gr_ gr_216 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="216" data-gr-id="216">side ?</g> Since <g class="gr_ gr_384 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="384" data-gr-id="384">shopping</g> chain side said they can only send numeric code, I have to translate them.

    Where do you find the information needed to map those <g class="gr_ gr_392 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="392" data-gr-id="392">codes ?</g> <g class="gr_ gr_464 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="464" data-gr-id="464">Shopping</g> chain will tell me the codes they will send instead of ABC123. For ABC123 <g class="gr_ gr_525 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="525" data-gr-id="525">may be</g> it is like 555444.

    Or that by design your <g class="gr_ gr_572 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="572" data-gr-id="572">existting</g> app generates <g class="gr_ gr_573 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="573" data-gr-id="573">alphanum</g> codes when your client can use only numerical codes ??? Nope, at the <g class="gr_ gr_660 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="660" data-gr-id="660">beginning</g> we tell the shopping chain that the codes are 123456, 123457 <g class="gr_ gr_721 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="721" data-gr-id="721">etc</g>. And they think they are only numeric.

    Why would you have to send ABC123 rather than a numeric <g class="gr_ gr_803 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="803" data-gr-id="803">code ?</g> <g class="gr_ gr_816 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="816" data-gr-id="816">You</g> get this id from the 3rd party service you are using ??? Yes, there is a new product and its code is ABC123. I get this code from 3rd party service.

    Wednesday, October 2, 2019 11:19 AM
  • User753101303 posted

    Ok so then it seems you have no other way than generating your own id for each alphanumerical generated by this service to serve that your client and it seems to make sense to keep that in a db, you don't have one already or which problem do you anticipate?

    Or maybe the ABC part has some special meaning ? It's not your own customer code in the 3rd party system for example. If fixed it could be just dropped...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 2, 2019 11:30 AM
  • User-1104215994 posted

    Ok so then it seems you have no other way than generating your own id for each alphanumerical generated by this service to serve that your client and it seems to make sense to keep that in a <g class="gr_ gr_4 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="4" data-gr-id="4">db</g>, you don't have one already or which problem do you anticipate?

    I am not sure but going one more time to the database makes me think twice.

    Wednesday, October 2, 2019 11:39 AM
  • User753101303 posted

    You are doing nothing at all in between using a db now already? You can always cache this in memory or maybe depending in your db use memory table (of course make sure new mappings are persisted).

    It's hard for others to suggest something on this kind of "micro-decision" that depends on the situation and it seems anyway that it would be easy to move your design forward if needed. Do something simple that works and just move forward as needed.

    Wednesday, October 2, 2019 11:49 AM
  • User475983607 posted

    It seems to me that you've designed a product code alias where the client knows nothing about the 3rd party product code.  Now your asking the community to come up with a design for code we know nothing about.

    cenk1536

    I am not sure but going one more time to the database makes me think twice.

    Logically the alias and product code must be stored in non-volatile location like a database.  If you are concerned about DB calls,  cache the product code to alias mapping.  Similar to your previous post related to device ID request throttling.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 2, 2019 11:53 AM