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

Create a wrapper object to call the different APIs #155

Closed
2 of 3 tasks
ignacio-chiazzo opened this issue Oct 14, 2024 · 0 comments
Closed
2 of 3 tasks

Create a wrapper object to call the different APIs #155

ignacio-chiazzo opened this issue Oct 14, 2024 · 0 comments
Labels
good first issue Good for newcomers hacktoberfest-accepted help wanted Extra attention is needed

Comments

@ignacio-chiazzo
Copy link
Owner

ignacio-chiazzo commented Oct 14, 2024

Today, there are different objects for each different domain:

  medias_api = WhatsappSdk::Api::Medias.new
  messages_api = WhatsappSdk::Api::Messages.new
  phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
  business_profile_api = WhatsappSdk::Api::BusinessProfile.new
  templates_api = WhatsappSdk::Api::Templates.new

We could simplify this by creating a singleton object Client that contains a link to the different APIs, like the following example:

client.messages # => returns an instance of WhatsappSdk::Api::Messages
client.medias # => returns an instance of WhatsappSdk::Api::Medias
#...

That would let the API much more clear like the followiong

client = Client.new 

# Messages
client.messages.send_text(
client.messages.send_reaction(
client.messages.send_image(
client.messages.send_audio

# Medias
client.media.upload
client.media.get
client.media.download

Tasks

  • Create a Client singleton object with attr_readers: media, messages, business_profile and phone_numbers here.
  • Add tests with the new API.
  • Update documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest-accepted help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant