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

Implement a better API #156

Merged
merged 6 commits into from
Oct 15, 2024
Merged

Implement a better API #156

merged 6 commits into from
Oct 15, 2024

Conversation

ignacio-chiazzo
Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo commented Oct 15, 2024

Solves #155

This PR introduces a new API to interact with the different API concerns. Instead of creating a new object per each area (media, messages, business_profiles etc) we can just call client. with the api name.

Before:

  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

  messages_api.get 
  #...
  phone_numbers_api.registered_number ...

After:

client.messages.send_text(....)

client.media.upload(....)

client.business_profiles.details

This PR also deprecates some methods:

Concern Before After
Business Profile client.business_profiles.details client.business_profiles.get
Phone Numbers client.phone_numbers.registered_numbers client.phone_numbers.list
Phone Numbers client.phone_numbers.registered_number client.phone_numbers.get
Templates client.templates.templates client.templates.list
Media client.medias.media client.medias.get

Note: I still maintain the old methods but raised a deprecated warning. I plan to remove them as part of 1.0.0.

To see the final API, see the README file.

…thods

Business_profile
- get in favour of details

Phone_number
- list in favour of registered_numbers
- get in favour of registered_number

Template
- list in favour of templates

Media
- get in favour of media
@ignacio-chiazzo ignacio-chiazzo merged commit 92b3ace into main Oct 15, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant