Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final step for url handling #10987

Closed
6 tasks done
NejcZdovc opened this issue Jul 29, 2020 · 1 comment
Closed
6 tasks done

Final step for url handling #10987

NejcZdovc opened this issue Jul 29, 2020 · 1 comment

Comments

@NejcZdovc
Copy link
Contributor

NejcZdovc commented Jul 29, 2020

@emerick did awesome job extracting all responses in separate folder. So now we need just do final step in this story. We need to merge request and response folder and create class per endpoint. This means every endpoint would have their own class. We should have abstracted class so that all endpoints would have the same structure.

Example class (for file in internals /endpoint/promotion/get_available/get_available.h):

namespace ledger {
namespace endpoint {
namespace promotion {

using GetAvailableCallback = std::function<void(
    const ledger::PromotionList&, 
    const std::vector<std::string>&)>;

class GetAvailable {
 public:
  explicit GetAvailable(bat_ledger::LedgerImpl* ledger);
  ~GetAvailable() override;

  void Request(GetAvailableCallback callback);

 private:
  std::string GetUrl(
    const std::string& payment_id,
    const std::string& platform);

  ledger::Result CheckStatusCode(const int32 status_code);

  ledger::Result ParseResponse(const std::string& body);

  void OnRequest(
    const ledger::UrlResponse& response,
    GetAvailableCallback callback);

  bat_ledger::LedgerImpl* ledger_;  // NOT OWNED
};

}  // namespace promotion
}  // namespace endpoint
}  // namespace ledger

Servers:

@NejcZdovc
Copy link
Contributor Author

all subtasks done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Brave Rewards
  
Done
Development

No branches or pull requests

1 participant