IAPProductInfo.cpp 991 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // IAPProductInfo.cpp
  3. // bulldog_sdk
  4. //
  5. // Created by zhuge on 2024/3/14.
  6. //
  7. #include "IAPProductInfo.h"
  8. #include "cocos2d.h"
  9. iap::IAPProductInfo::IAPProductInfo(const std::string& productId, const std::string& name, const std::string& desc, const std::string& displayPrice )
  10. : _productId(productId)
  11. , _name(name)
  12. , _desc(desc)
  13. , _displayPrice(displayPrice)
  14. {
  15. }
  16. iap::IAPProductInfo::IAPProductInfo(const std::string& jsonString)
  17. : _productId("")
  18. , _name("")
  19. , _desc("")
  20. , _displayPrice("")
  21. {
  22. std::string err = "";
  23. json11::Json json = json11::Json::parse(jsonString, err);
  24. if (!err.empty() && json.is_null()) {
  25. // log error
  26. } else {
  27. auto joRoot = json.object_items();
  28. _productId = joRoot.at("productId").string_value();
  29. _name = joRoot.at("name").string_value();
  30. _desc = joRoot.at("desc").string_value();
  31. _displayPrice = joRoot.at("displayPrice").string_value();
  32. }
  33. }
  34. iap::IAPProductInfo::~IAPProductInfo() {}