2016-10-18 7 views
1

ネイティブモバイルアプリを作成したいと思っています。IntershopのREST APIを使用してカートに商品を追加します。その部分は簡単です。しかし、チェックアウトのために私は標準的な応答性のあるWebアプリケーションを使用したいと思います。どのようにこれらの2つのアプローチがエレガントに混合できるかについての示唆はありますか?REST APIの使用方法とレスポンシブ・チェックアウトの比較

答えて

0

私は現在、REST API経由で作成されたバスケットを現在のセッションに接続する小さなパイプレットを作成して解決しました。

public class AttachBasketToSession extends Pipelet 
    { 
     @Inject 
     CurrentApplicationBOProvider currentApplicationBOprovider; 

     @Override 
     public int execute(PipelineDictionary aPipelineDictionary) throws PipeletExecutionException 
     { 
      String basketUUID = aPipelineDictionary.get("BasketUUID"); 
      String userID = aPipelineDictionary.get("UserID"); 
      StorefrontSession session = aPipelineDictionary.get("CurrentSession"); 

      ApplicationBO applicationBO = currentApplicationBOprovider.get(); 
      BasketBORepository basketBORepository = applicationBO.getRepository("BasketBORepository"); 
      UserBORepository userBORepository = applicationBO.getRepository("UserBORepository"); 

      BasketBO basketBO = basketBORepository.getBasketBO(basketUUID); 
      UserBO userBO = userBORepository.getUserBOByID(userID); 

      // Set the current user as owner of the new basket 
      basketBO.setUserBO(userBO); 

      // Assign the basket to the session 
      Map<String, String> basketUUIDs = (Map)session.getObject("BasketUUIDs"); 
      for (String key : basketUUIDs.keySet()) 
      { 
       basketUUIDs.put(key, basketBO.getID()); 
       break; // Assume there is only one basket attached to the session 

      } 
      session.putObject("BasketUUIDs", basketUUIDs); 

      return PIPELET_NEXT; 

     } 
} 
関連する問題