How ignacio-chiazzo/ruby_whatsapp_sdk works
Main Components
• Client Initialization & Configuration:
– Represent the configuration block (see examples under “Option 1” in the README) where the user sets access tokens, API version, and logger details.
– This maps to the configuration code in lib/whatsapp_sdk/configuration.rb and the client wrapper in lib/whatsapp_sdk/api/client.rb.
• API Client:
– Show the central “Client” component (WhatsappSdk::Api::Client) that users instantiate.
– This client serves as a façade for the various API operations.
• API Endpoints (Modules):
▪ Messages – from lib/whatsapp_sdk/api/messages.rb (and associated response classes in lib/whatsapp_sdk/api/responses).
▪ Media – for uploading, downloading, and deleting media (library under lib/whatsapp_sdk/api/medias.rb).
▪ Phone Numbers – managing registration and queries (in lib/whatsapp_sdk/api/phone_numbers.rb).
▪ Business Profiles – for getting and updating business information.
▪ Templates – for creating, updating, and deleting message templates.
• Resource Classes:
– Under lib/whatsapp_sdk/resource, list the various resource classes that model the data objects (such as Message, Media, Currency, DateTime, etc.). These handle conversion and validations before being sent to the API.
• Error Handling:
– Include a component (like “Error Handler” or “Response Handler”) to represent modules such as WhatsappSdk::Error and the responses under lib/whatsapp_sdk/api/responses.
• External Service:
Out the Relationships and Data Flow
• This configuration feeds into the API Client.
• Each of these modules utilizes one or several resource classes to structure data payloads.
• Additionally, include a pathway for error handling where API responses are parsed and exceptions such as HttpResponseError are raised.
Architectural Patterns
• That the SDK is designed using a modular and layered architecture:
– A configuration layer (initialization).
– An abstraction layer (the API Client and endpoint modules that encapsulate HTTP calls).
– A presentation/representation layer (the Resource classes that define the data model for messages, media, etc.).
• This separation provides clear responsibilities and makes testing easier—as seen by the comprehensive test directory.
Additional Elements
• Optionally, reference CI/CD configurations (located in .circleci, .github, .travis.yml) as part of the project’s overall architecture for automated testing and deployment.
• Finally, mention the gemspec and setup scripts (bin/setup, Rakefile) as part of the build/installation process.