airbridge_deeplink 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 00c5519267b36ebc52120fd14ab616d7c0e8989f30d41f54e5754343e81e9aed
4
+ data.tar.gz: ecc98eeab757b2f031ccc23488468ab4a650d798cc597071fb784961e6344866
5
+ SHA512:
6
+ metadata.gz: 118eb5f5e6f062da7e50fff8893b2ad34a5e72e664abba700d70be5ccd0283c056e5b359cf500cde6472ed5ef4054f3d87839442e30c7b48a16ecfb58b7c72bb
7
+ data.tar.gz: 91022fd092ded21792257db83fd64452111c47c60b2935529abf60943366fb9d60203b8ae3561f54a03ca9e0faee39f068db7470fe98b583038ff236c138870a
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.6
6
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2025-08-11
11
+
12
+ ### Added
13
+ - Initial release of AirbridgeDeeplink gem
14
+ - Basic configuration system with API token support
15
+ - Client class for interacting with Airbridge API
16
+ - `create_tracking_link` method with full parameter support
17
+ - Comprehensive error handling for API responses
18
+ - Full test coverage with RSpec and WebMock
19
+ - English documentation and examples
20
+ - Support for all Airbridge API parameters:
21
+ - channel (required)
22
+ - campaignParams (campaign, ad_group, ad_creative)
23
+ - isReengagement
24
+ - deeplinkOption
25
+ - fallbackPaths
26
+ - ogTag
27
+
28
+ ### Dependencies
29
+ - HTTParty for HTTP requests
30
+ - JSON for JSON parsing
31
+ - RSpec, WebMock, VCR for testing
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at superp1987@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in airbridge_deeplink.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ airbridge_deeplink (0.1.0)
5
+ httparty (~> 0.21)
6
+ json (~> 2.6)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.7)
12
+ public_suffix (>= 2.0.2, < 7.0)
13
+ base64 (0.3.0)
14
+ bigdecimal (3.2.2)
15
+ crack (1.0.0)
16
+ bigdecimal
17
+ rexml
18
+ csv (3.3.5)
19
+ diff-lcs (1.6.2)
20
+ hashdiff (1.2.0)
21
+ httparty (0.23.1)
22
+ csv
23
+ mini_mime (>= 1.0.0)
24
+ multi_xml (>= 0.5.2)
25
+ json (2.13.2)
26
+ mini_mime (1.1.5)
27
+ multi_xml (0.6.0)
28
+ public_suffix (5.1.1)
29
+ rake (13.3.0)
30
+ rexml (3.4.1)
31
+ rspec (3.13.1)
32
+ rspec-core (~> 3.13.0)
33
+ rspec-expectations (~> 3.13.0)
34
+ rspec-mocks (~> 3.13.0)
35
+ rspec-core (3.13.5)
36
+ rspec-support (~> 3.13.0)
37
+ rspec-expectations (3.13.5)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.13.0)
40
+ rspec-mocks (3.13.5)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.13.0)
43
+ rspec-support (3.13.4)
44
+ vcr (6.3.1)
45
+ base64
46
+ webmock (3.25.1)
47
+ addressable (>= 2.8.0)
48
+ crack (>= 0.3.2)
49
+ hashdiff (>= 0.4.0, < 2.0.0)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ airbridge_deeplink!
56
+ httparty (~> 0.21)
57
+ rake (~> 13.0)
58
+ rspec (~> 3.0)
59
+ vcr (~> 6.1)
60
+ webmock (~> 3.18)
61
+
62
+ BUNDLED WITH
63
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 superp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # AirbridgeDeeplink
2
+
3
+ Ruby gem for creating Airbridge deeplinks via their API.
4
+
5
+ ## Installation
6
+
7
+ Add this gem to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'airbridge_deeplink'
11
+ ```
12
+
13
+ Or install it directly:
14
+
15
+ ```bash
16
+ gem install airbridge_deeplink
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Basic Configuration
22
+
23
+ ```ruby
24
+ # In initializer or config file
25
+ AirbridgeDeeplink.api_token = 'your-airbridge-api-token'
26
+
27
+ # Or through configuration block
28
+ AirbridgeDeeplink.configure do |config|
29
+ config.api_token = 'your-airbridge-api-token'
30
+ config.timeout = 30
31
+ end
32
+ ```
33
+
34
+ ### Creating Tracking Links
35
+
36
+ ```ruby
37
+ # Create client
38
+ client = AirbridgeDeeplink::Client.new
39
+
40
+ # Basic example
41
+ options = {
42
+ channel: "my-channel"
43
+ }
44
+
45
+ response = client.create_tracking_link(options)
46
+
47
+ # Extended example with all parameters
48
+ options = {
49
+ channel: "my-channel",
50
+ campaignParams: {
51
+ campaign: "2022_FW_Sale_Festival",
52
+ ad_group: "UA",
53
+ ad_creative: "Coat_840x600"
54
+ },
55
+ isReengagement: "OFF",
56
+ deeplinkUrl: "openmyapp://festival/38",
57
+ deeplinkOption: {
58
+ showAlertForInitialDeeplinkingIssue: true
59
+ },
60
+ fallbackPaths: {
61
+ android: "google-play",
62
+ ios: "itunes-appstore",
63
+ desktop: "https://example.com"
64
+ },
65
+ ogTag: {
66
+ title: "30% Off Winter Apparel for 3 Days Only",
67
+ description: "Get great deals on apparel to keep you warm this winter",
68
+ imageUrl: "https://static.airbridge.io/images/2021_airbridge_og_tag.png"
69
+ }
70
+ }
71
+
72
+ response = client.create_tracking_link(options)
73
+ ```
74
+
75
+ ## API Parameters
76
+
77
+ ### Required Parameters
78
+
79
+ - `channel` - Channel name for tracking link
80
+
81
+ ### Optional Parameters
82
+
83
+ - `campaignParams` - Campaign parameters
84
+ - `campaign` - Campaign name
85
+ - `ad_group` - Ad group
86
+ - `ad_creative` - Ad creative
87
+ - `isReengagement` - Re-engagement parameter ("ON-TRUE" or "OFF-FALSE")
88
+ - `deeplinkUrl` - Configure the Deeplink URL for redirect.
89
+ - `deeplinkOption` - Deeplink settings
90
+ - `showAlertForInitialDeeplinkingIssue` - Show alert for deeplink issues
91
+ - `fallbackPaths` - Fallback paths
92
+ - `android` - Redirect android user to google-play, airpage or http(s) url
93
+ - `ios` - Redirect iOS user to itunes-appstore, airpage or http(s) url
94
+ - `desktop` - Redirect desktop user to google-play, itunes-appstore or http(s) url
95
+ - `option` - Fallback options
96
+ - `iosCustomProductPageId` - iOS custom product page ID
97
+ - `googlePlayCustomStoreListing` - Google Play custom store listing
98
+ - `ogTag` - Open Graph tags
99
+ - `title` - Title
100
+ - `description` - Description
101
+ - `imageUrl` - Image URL
102
+
103
+ ## Error Handling
104
+
105
+ The gem provides specific error classes:
106
+
107
+ ```ruby
108
+ begin
109
+ response = client.create_tracking_link(options)
110
+ rescue AirbridgeDeeplink::ConfigurationError => e
111
+ puts "Configuration error: #{e.message}"
112
+ rescue AirbridgeDeeplink::APIError => e
113
+ puts "API error: #{e.message}"
114
+ rescue ArgumentError => e
115
+ puts "Invalid parameters: #{e.message}"
116
+ end
117
+ ```
118
+
119
+ ## Development
120
+
121
+ After cloning the repository, run:
122
+
123
+ ```bash
124
+ bundle install
125
+ ```
126
+
127
+ To run tests:
128
+
129
+ ```bash
130
+ bundle exec rspec
131
+ ```
132
+
133
+ ## License
134
+
135
+ This gem is available under the MIT license. See the LICENSE file for details.
136
+
137
+ ## Contributing
138
+
139
+ 1. Fork the project
140
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
141
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
142
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
143
+ 5. Open a Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/airbridge_deeplink/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'airbridge_deeplink'
7
+ spec.version = AirbridgeDeeplink::VERSION
8
+ spec.authors = ['superp']
9
+ spec.email = ['superp1987@gmail.com']
10
+
11
+ spec.summary = 'Ruby gem for creating Airbridge deeplinks via their API'
12
+ spec.description = 'A simple Ruby gem to interact with Airbridge API for creating tracking links and deeplinks'
13
+ spec.homepage = 'https://github.com/superp/airbridge_deeplink'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = spec.homepage
19
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ # Add dependencies
31
+ spec.add_dependency 'httparty', '~> 0.21'
32
+ spec.add_dependency 'json', '~> 2.6'
33
+
34
+ # Add development dependencies
35
+ spec.add_development_dependency 'rake', '~> 13.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'vcr', '~> 6.1'
38
+ spec.add_development_dependency 'webmock', '~> 3.18'
39
+ end
data/bin/console ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "airbridge_deeplink"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # Example usage:
10
+ puts "AirbridgeDeeplink gem loaded!"
11
+ puts "Version: #{AirbridgeDeeplink::VERSION}"
12
+ puts ""
13
+ puts "Example usage:"
14
+ puts " AirbridgeDeeplink.api_token = 'your-api-token'"
15
+ puts " client = AirbridgeDeeplink::Client.new"
16
+ puts " response = client.create_tracking_link(channel: 'my-channel')"
17
+ puts ""
18
+
19
+ # (If you use this, don't forget to add pry to your Gemfile!)
20
+ # require "pry"
21
+ # Pry.start
22
+
23
+ require "irb"
24
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/airbridge_deeplink'
4
+
5
+ # Set API token
6
+ AirbridgeDeeplink.api_token = 'your-airbridge-api-token'
7
+
8
+ # Create client
9
+ client = AirbridgeDeeplink::Client.new
10
+
11
+ # Basic example of creating tracking link
12
+ puts "Creating basic tracking link..."
13
+ begin
14
+ response = client.create_tracking_link(
15
+ channel: "my-channel"
16
+ )
17
+ puts "Successfully created: #{response}"
18
+ rescue => e
19
+ puts "Error: #{e.message}"
20
+ end
21
+
22
+ # Extended example with all parameters
23
+ puts "\nCreating extended tracking link..."
24
+ begin
25
+ options = {
26
+ channel: "my-channel",
27
+ campaignParams: {
28
+ campaign: "2022_FW_Sale_Festival",
29
+ ad_group: "UA",
30
+ ad_creative: "Coat_840x600"
31
+ },
32
+ isReengagement: "ON-TRUE",
33
+ deeplinkOption: {
34
+ showAlertForInitialDeeplinkingIssue: true
35
+ },
36
+ fallbackPaths: {
37
+ option: {
38
+ iosCustomProductPageId: "5ae82ffe-1f08-428d-b352-ac1c3a22aa1e",
39
+ googlePlayCustomStoreListing: "custom-store-listing"
40
+ }
41
+ },
42
+ ogTag: {
43
+ title: "30% Off Winter Apparel for 3 Days Only",
44
+ description: "Get great deals on apparel to keep you warm this winter",
45
+ imageUrl: "https://static.airbridge.io/images/2021_airbridge_og_tag.png"
46
+ }
47
+ }
48
+
49
+ response = client.create_tracking_link(options)
50
+ puts "Successfully created extended tracking link: #{response}"
51
+ rescue => e
52
+ puts "Error: #{e.message}"
53
+ end
54
+
55
+ # Error handling example
56
+ puts "\nTesting error handling..."
57
+ begin
58
+ # Try to create tracking link without channel
59
+ response = client.create_tracking_link({})
60
+ rescue ArgumentError => e
61
+ puts "Expected validation error: #{e.message}"
62
+ rescue AirbridgeDeeplink::APIError => e
63
+ puts "API error: #{e.message}"
64
+ rescue => e
65
+ puts "Unexpected error: #{e.message}"
66
+ end
@@ -0,0 +1,81 @@
1
+ # app/controllers/tracking_links_controller.rb
2
+
3
+ class TrackingLinksController < ApplicationController
4
+ def create
5
+ # Create client
6
+ client = AirbridgeDeeplink::Client.new
7
+
8
+ # Parameters for tracking link
9
+ options = {
10
+ channel: params[:channel],
11
+ campaignParams: {
12
+ campaign: params[:campaign],
13
+ ad_group: params[:ad_group],
14
+ ad_creative: params[:ad_creative]
15
+ },
16
+ isReengagement: params[:is_reengagement] || "OFF-FALSE",
17
+ deeplinkOption: {
18
+ showAlertForInitialDeeplinkingIssue: params[:show_alert] || false
19
+ }
20
+ }
21
+
22
+ # Add fallback paths if specified
23
+ if params[:ios_custom_product_page_id] || params[:google_play_custom_store_listing]
24
+ options[:fallbackPaths] = {
25
+ option: {
26
+ iosCustomProductPageId: params[:ios_custom_product_page_id],
27
+ googlePlayCustomStoreListing: params[:google_play_custom_store_listing]
28
+ }.compact
29
+ }
30
+ end
31
+
32
+ # Add OG tags if specified
33
+ if params[:og_title] || params[:og_description] || params[:og_image_url]
34
+ options[:ogTag] = {
35
+ title: params[:og_title],
36
+ description: params[:og_description],
37
+ imageUrl: params[:og_image_url]
38
+ }.compact
39
+ end
40
+
41
+ begin
42
+ # Create tracking link
43
+ response = client.create_tracking_link(options)
44
+
45
+ render json: {
46
+ success: true,
47
+ tracking_link: response
48
+ }
49
+ rescue AirbridgeDeeplink::ConfigurationError => e
50
+ render json: {
51
+ success: false,
52
+ error: "Configuration error: #{e.message}"
53
+ }, status: :internal_server_error
54
+ rescue AirbridgeDeeplink::APIError => e
55
+ render json: {
56
+ success: false,
57
+ error: "API error: #{e.message}"
58
+ }, status: :bad_request
59
+ rescue ArgumentError => e
60
+ render json: {
61
+ success: false,
62
+ error: "Invalid parameters: #{e.message}"
63
+ }, status: :unprocessable_entity
64
+ rescue => e
65
+ render json: {
66
+ success: false,
67
+ error: "Unexpected error: #{e.message}"
68
+ }, status: :internal_server_error
69
+ end
70
+ end
71
+
72
+ private
73
+
74
+ def tracking_link_params
75
+ params.permit(
76
+ :channel, :campaign, :ad_group, :ad_creative, :is_reengagement,
77
+ :show_alert, :ios_custom_product_page_id, :google_play_custom_store_listing,
78
+ :og_title, :og_description, :og_image_url
79
+ )
80
+ end
81
+ end
@@ -0,0 +1,18 @@
1
+ # config/initializers/airbridge_deeplink.rb
2
+
3
+ # Configure AirbridgeDeeplink gem
4
+ AirbridgeDeeplink.configure do |config|
5
+ # Set API token from environment variable
6
+ config.api_token = ENV['AIRBRIDGE_API_TOKEN']
7
+
8
+ # Optionally: configure timeout (default is 30 seconds)
9
+ config.timeout = 30
10
+
11
+ # Optionally: change base URL (default is https://api.airbridge.io/v1)
12
+ # config.base_url = "https://api.airbridge.io/v1"
13
+ end
14
+
15
+ # Check if API token is set
16
+ unless AirbridgeDeeplink.api_token
17
+ Rails.logger.warn "AirbridgeDeeplink: AIRBRIDGE_API_TOKEN is not set in environment variables"
18
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+
5
+ module AirbridgeDeeplink
6
+ class Client
7
+ include HTTParty
8
+
9
+ base_uri 'https://api.airbridge.io/v1'
10
+ headers 'Content-Type' => 'application/json'
11
+ default_timeout 30
12
+
13
+ def initialize(config = nil)
14
+ @config = config || AirbridgeDeeplink.configuration
15
+ @config.validate!
16
+
17
+ self.class.headers 'Authorization' => "Bearer #{@config.api_token}"
18
+ end
19
+
20
+ def create_tracking_link(options = {})
21
+ validate_tracking_link_options(options)
22
+
23
+ response = self.class.post('/tracking-links', body: options.to_json)
24
+
25
+ handle_response(response)
26
+ end
27
+
28
+ private
29
+
30
+ def validate_tracking_link_options(options)
31
+ required_fields = [:channel]
32
+ missing_fields = required_fields.select { |field| options[field].nil? || options[field].to_s.empty? }
33
+
34
+ if missing_fields.any?
35
+ raise ArgumentError, "Missing required fields: #{missing_fields.join(', ')}"
36
+ end
37
+ end
38
+
39
+ def handle_response(response)
40
+ case response.code
41
+ when 200, 201
42
+ JSON.parse(response.body)
43
+ when 400
44
+ raise APIError, "Bad Request: #{response.body}"
45
+ when 401
46
+ raise APIError, 'Unauthorized: Invalid API token'
47
+ when 403
48
+ raise APIError, 'Forbidden: Insufficient permissions'
49
+ when 404
50
+ raise APIError, "Not Found: #{response.body}"
51
+ when 429
52
+ raise APIError, 'Rate Limited: Too many requests'
53
+ when 500..599
54
+ raise APIError, "Server Error: #{response.body}"
55
+ else
56
+ raise APIError, "Unexpected response (#{response.code}): #{response.body}"
57
+ end
58
+ rescue JSON::ParserError
59
+ raise APIError, "Invalid JSON response: #{response.body}"
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbridgeDeeplink
4
+ class Configuration
5
+ attr_accessor :api_token, :base_url, :timeout
6
+
7
+ def initialize
8
+ @api_token = nil
9
+ @base_url = 'https://api.airbridge.io/v1'
10
+ @timeout = 30
11
+ end
12
+
13
+ def validate!
14
+ raise ConfigurationError, 'API token is required' if api_token.blank?
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AirbridgeDeeplink
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'airbridge_deeplink/version'
4
+ require 'airbridge_deeplink/client'
5
+ require 'airbridge_deeplink/configuration'
6
+ require 'httparty'
7
+ require 'json'
8
+ require 'delegate'
9
+
10
+ module AirbridgeDeeplink
11
+ class Error < StandardError; end
12
+ class ConfigurationError < Error; end
13
+ class APIError < Error; end
14
+
15
+ class << self
16
+ def configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def configure
21
+ yield(configuration)
22
+ end
23
+
24
+ def api_token
25
+ configuration.api_token
26
+ end
27
+
28
+ def api_token=(token)
29
+ configuration.api_token = token
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: airbridge_deeplink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - superp
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.21'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.21'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '6.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '6.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.18'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.18'
97
+ description: A simple Ruby gem to interact with Airbridge API for creating tracking
98
+ links and deeplinks
99
+ email:
100
+ - superp1987@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CHANGELOG.md
109
+ - CODE_OF_CONDUCT.md
110
+ - Gemfile
111
+ - Gemfile.lock
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - airbridge_deeplink.gemspec
116
+ - bin/console
117
+ - bin/setup
118
+ - examples/basic_usage.rb
119
+ - examples/rails_controller_example.rb
120
+ - examples/rails_initializer.rb
121
+ - lib/airbridge_deeplink.rb
122
+ - lib/airbridge_deeplink/client.rb
123
+ - lib/airbridge_deeplink/configuration.rb
124
+ - lib/airbridge_deeplink/version.rb
125
+ homepage: https://github.com/superp/airbridge_deeplink
126
+ licenses:
127
+ - MIT
128
+ metadata:
129
+ homepage_uri: https://github.com/superp/airbridge_deeplink
130
+ source_code_uri: https://github.com/superp/airbridge_deeplink
131
+ changelog_uri: https://github.com/superp/airbridge_deeplink/blob/main/CHANGELOG.md
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 2.6.0
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubygems_version: 3.1.6
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Ruby gem for creating Airbridge deeplinks via their API
151
+ test_files: []