namabar 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/sig/client.rbs ADDED
@@ -0,0 +1,65 @@
1
+ module Namabar
2
+ # HTTP client for interacting with the Namabar API
3
+ #
4
+ # This class provides the core HTTP functionality for making requests to the Namabar API.
5
+ # It uses HTTParty for HTTP operations and includes all endpoint methods from the Endpoints module.
6
+ #
7
+ # The client automatically handles:
8
+ # - Base URI configuration
9
+ # - Authentication via API key headers
10
+ # - Content-Type and Accept headers
11
+ # - JSON request/response handling
12
+ #
13
+ # @example Basic usage
14
+ # # Configure globally first
15
+ # Namabar.configure do |config|
16
+ # config.api_key = 'your-api-key'
17
+ # end
18
+ #
19
+ # # Create and use client
20
+ # client = Namabar::Client.new
21
+ # response = client.send_message(
22
+ # type: 'sms',
23
+ # to: '+1234567890',
24
+ # text: 'Hello from Namabar!',
25
+ # service_id: 'sms-service'
26
+ # )
27
+ # puts response.code # => 200
28
+ # puts response.body # => parsed JSON response
29
+ #
30
+ # @see Endpoints
31
+ # @see Configuration
32
+ class Client
33
+ @config: Configuration
34
+
35
+ include HTTParty
36
+ include Endpoints
37
+
38
+ # Initialize a new Namabar API client
39
+ #
40
+ # Creates a new client instance using the global Namabar configuration.
41
+ # The client will be configured with the API key and default headers
42
+ # required for authentication and proper JSON communication.
43
+ #
44
+ # @raise [StandardError] if Namabar.configuration is nil or api_key is not set
45
+ #
46
+ # @example Create a client
47
+ # client = Namabar::Client.new
48
+ #
49
+ # @see Namabar.configure
50
+ def initialize: () -> void
51
+
52
+ # Get default HTTP options for requests
53
+ #
54
+ # Returns a hash containing the default options that should be included
55
+ # with every HTTP request, including headers for authentication and content type.
56
+ #
57
+ # @return [Hash] hash containing default headers and options
58
+ #
59
+ # @example Using default options
60
+ # opts = client.default_options
61
+ # opts = opts.merge(query: { limit: 10 })
62
+ # response = HTTParty.get('/endpoint', opts)
63
+ def default_options: () -> { headers: Hash[String, String] }
64
+ end
65
+ end
@@ -0,0 +1,50 @@
1
+ module Namabar
2
+ # Configuration class for storing Namabar API credentials and settings
3
+ #
4
+ # This class holds the configuration options required to authenticate
5
+ # and interact with the Namabar API. It's typically configured once
6
+ # globally and then used by all Client instances.
7
+ #
8
+ # @example Configure with API credentials
9
+ # config = Namabar::Configuration.new
10
+ # config.api_key = ENV.fetch('NAMABAR__API_KEY', nil)
11
+ #
12
+ # @example Configure using the global configuration
13
+ # Namabar.configure do |config|
14
+ # config.api_key = 'your-api-key'
15
+ # end
16
+ #
17
+ # @see Namabar.configure
18
+ class Configuration
19
+ # @return [String, nil] the API key for authenticating with the Namabar API
20
+ # @example Set API key
21
+ # config.api_key = 'sk_live_1234567890abcdef'
22
+ attr_accessor api_key: String?
23
+ end
24
+
25
+ # @return [Configuration, nil] the global configuration instance
26
+ attr_accessor self.configuration: Configuration?
27
+
28
+ # Configure the Namabar gem with API credentials and settings
29
+ #
30
+ # This method provides a convenient way to set up the global configuration
31
+ # that will be used by all Client instances. The configuration object is
32
+ # yielded to the provided block for modification.
33
+ #
34
+ # @yield [config] Yields the configuration object for modification
35
+ # @yieldparam config [Configuration] the configuration instance to modify
36
+ # @return [Configuration] the configured Configuration instance
37
+ #
38
+ # @example Basic configuration
39
+ # Namabar.configure do |config|
40
+ # config.api_key = ENV.fetch('NAMABAR__API_KEY', nil)
41
+ # end
42
+ #
43
+ # @example Configuration with validation
44
+ # Namabar.configure do |config|
45
+ # config.api_key = ENV.fetch('NAMABAR_API_KEY') { raise 'API key required' }
46
+ # end
47
+ #
48
+ # @see Configuration
49
+ def self.configure: () { (Configuration) -> void } -> Configuration
50
+ end
data/sig/endpoints.rbs ADDED
@@ -0,0 +1,44 @@
1
+ module Namabar
2
+ module Endpoints
3
+ # Create Verification Code
4
+ # @param to [String] (required)
5
+ # @param locale [(String | nil)] (optional)
6
+ # @param external_id [(String | nil)] (optional)
7
+ # @param code [(String | nil)] (optional)
8
+ # @param service_id [String] (required)
9
+ # @param template_data [(Hash[String, untyped] | nil)] (optional)
10
+ # @return [HTTParty::Response]
11
+ def create_verification_code: (to: String, ?locale: (String | nil), ?external_id: (String | nil), ?code: (String | nil), service_id: String, ?template_data: (Hash[String, untyped] | nil)) -> HTTParty::Response
12
+
13
+ # Verify Verification Code
14
+ # @param id [String] (required)
15
+ # @param code [String] (required)
16
+ # @return [HTTParty::Response]
17
+ def verify_verification_code: (id: String, code: String) -> HTTParty::Response
18
+
19
+ # Get Verification Code By Id
20
+ # @param id [String] (required)
21
+ # @return [HTTParty::Response]
22
+ def get_verification_code_by_id: (id: String) -> HTTParty::Response
23
+
24
+ # Send Message
25
+ # @param type [String] (required)
26
+ # @param to [String] (required)
27
+ # @param external_id [(String | nil)] (optional)
28
+ # @param service_id [String] (required)
29
+ # @param text [(String | nil)] (optional)
30
+ # @param template [(String | nil)] (optional)
31
+ # @return [HTTParty::Response]
32
+ def send_message: (type: String, to: String, ?external_id: (String | nil), service_id: String, ?text: (String | nil), ?template: (String | nil)) -> HTTParty::Response
33
+
34
+ # Get Message
35
+ # @param id [String] (required)
36
+ # @return [HTTParty::Response]
37
+ def get_message: (id: String) -> HTTParty::Response
38
+
39
+ # Get Message Status
40
+ # @param id [String] (required)
41
+ # @return [HTTParty::Response]
42
+ def get_message_status: (id: String) -> HTTParty::Response
43
+ end
44
+ end
data/sig/namabar.rbs ADDED
@@ -0,0 +1,68 @@
1
+ # The main Namabar module providing convenient access to the Namabar API
2
+ #
3
+ # This module serves as the primary entry point for the Namabar gem, offering:
4
+ # - Global configuration management
5
+ # - Client creation and management
6
+ # - Error handling for the entire gem
7
+ #
8
+ # @example Basic usage
9
+ # Namabar.configure do |config|
10
+ # config.api_key = ENV.fetch('NAMABAR__API_KEY', nil)
11
+ # end
12
+ #
13
+ # client = Namabar.client
14
+ # response = client.send_message(...)
15
+ #
16
+ # @see Client
17
+ # @see Configuration
18
+ module Namabar
19
+ # Base error class for all Namabar-related errors
20
+ #
21
+ # All errors raised by the Namabar gem inherit from this class,
22
+ # making it easy to rescue all gem-related errors with a single rescue clause.
23
+ #
24
+ # @example Rescuing all Namabar errors
25
+ # begin
26
+ # client.send_message(...)
27
+ # rescue Namabar::Error => e
28
+ # puts "Namabar error: #{e.message}"
29
+ # end
30
+ class Error < StandardError
31
+ end
32
+
33
+ # @return [Configuration, nil] the current global configuration instance
34
+ attr_accessor self.configuration: Configuration?
35
+
36
+ # Configure the Namabar gem globally
37
+ #
38
+ # This method allows you to set global configuration options that will be
39
+ # used by all Client instances unless overridden. The configuration is
40
+ # yielded to the provided block for modification.
41
+ #
42
+ # @yield [config] Yields the configuration object for modification
43
+ # @yieldparam config [Configuration] the configuration instance to modify
44
+ # @return [Configuration] the configured Configuration instance
45
+ #
46
+ # @example Configure API credentials
47
+ # Namabar.configure do |config|
48
+ # config.api_key = ENV.fetch('NAMABAR__API_KEY', nil)
49
+ # end
50
+ #
51
+ # @see Configuration
52
+ def self.configure: () { (Configuration) -> void } -> Configuration
53
+
54
+ # Create a new Namabar API client
55
+ #
56
+ # Creates and returns a new Client instance using the global configuration.
57
+ # This is a convenience method equivalent to calling Client.new directly.
58
+ #
59
+ # @param args [Array] arguments to pass to the Client constructor (currently none accepted)
60
+ # @return [Client] a new configured client instance
61
+ #
62
+ # @example Create a client
63
+ # client = Namabar.client
64
+ # response = client.send_message(...)
65
+ #
66
+ # @see Client#initialize
67
+ def self.client: (*untyped args) -> Client
68
+ end
data/sig/version.rbs ADDED
@@ -0,0 +1,15 @@
1
+ module Namabar
2
+ # The current version of the Namabar gem
3
+ #
4
+ # This constant follows semantic versioning (SemVer) conventions:
5
+ # - MAJOR: Incompatible API changes
6
+ # - MINOR: Backwards-compatible functionality additions
7
+ # - PATCH: Backwards-compatible bug fixes
8
+ #
9
+ # @return [String] the current version string
10
+ # @example Check the version
11
+ # puts Namabar::VERSION # => "0.1.0"
12
+ #
13
+ # @see https://semver.org/ Semantic Versioning specification
14
+ VERSION: String
15
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: namabar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Muhammad Nawzad
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-05-31 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: httparty
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '0.2'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.2.0
32
+ description: A lightweight Ruby SDK providing HTTParty-based client with type definitions
33
+ for the Namabar OTP verification and messaging platform.
34
+ email:
35
+ - hama127n@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".rspec"
41
+ - ".rubocop.yml"
42
+ - CHANGELOG.md
43
+ - CODE_OF_CONDUCT.md
44
+ - Gemfile
45
+ - Gemfile.lock
46
+ - LICENSE.txt
47
+ - README.md
48
+ - Rakefile
49
+ - bin/console
50
+ - bin/setup
51
+ - lib/namabar.rb
52
+ - lib/namabar/client.rb
53
+ - lib/namabar/configuration.rb
54
+ - lib/namabar/endpoints.rb
55
+ - lib/namabar/version.rb
56
+ - namabar.gemspec
57
+ - sig/client.rbs
58
+ - sig/configuration.rbs
59
+ - sig/endpoints.rbs
60
+ - sig/namabar.rbs
61
+ - sig/version.rbs
62
+ homepage: https://github.com/muhammadnawzad/namabar-ruby-sdk
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ homepage_uri: https://github.com/muhammadnawzad/namabar-ruby-sdk
67
+ changelog_uri: https://github.com/muhammadnawzad/namabar-ruby-sdk/blob/main/CHANGELOG.md
68
+ documentation_uri: https://rubydoc.info/gems/namabar
69
+ bug_tracker_uri: https://github.com/muhammadnawzad/namabar-ruby-sdk/issues
70
+ allowed_push_host: https://rubygems.org
71
+ rubygems_mfa_required: 'true'
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 3.1.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.6.5
87
+ specification_version: 4
88
+ summary: Ruby SDK for Namabar OTP verification and messaging API
89
+ test_files: []