-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from piscespieces/add-location-header-to-temp…
…lates Add location header to templates
- Loading branch information
Showing
7 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module WhatsappSdk | ||
module Resource | ||
class Location | ||
extend T::Sig | ||
|
||
# Returns the latitude of the location. | ||
# | ||
# @returns latitude [Float]. | ||
sig { returns(T.nilable(Float)) } | ||
attr_accessor :latitude | ||
|
||
# Returns the longitude of the location. | ||
# | ||
# @returns longitude [Float]. | ||
sig { returns(T.nilable(Float)) } | ||
attr_accessor :longitude | ||
|
||
# Returns the name of the location. | ||
# | ||
# @returns name [String]. | ||
sig { returns(T.nilable(String)) } | ||
attr_accessor :name | ||
|
||
# Returns the address of the location. | ||
# | ||
# @returns address [String]. | ||
sig { returns(T.nilable(String)) } | ||
attr_accessor :address | ||
|
||
sig { params(latitude: Float, longitude: Float, name: String, address: String).void } | ||
def initialize(latitude:, longitude:, name:, address:) | ||
@latitude = latitude | ||
@longitude = longitude | ||
@name = name | ||
@address = address | ||
end | ||
|
||
sig { returns(T::Hash[T.untyped, T.untyped]) } | ||
def to_json | ||
{ | ||
latitude: latitude, | ||
longitude: longitude, | ||
name: name, | ||
address: address | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
require "test_helper" | ||
require "resource/location" | ||
|
||
module WhatsappSdk | ||
module Resource | ||
module Resource | ||
class LocationTest < Minitest::Test | ||
def test_to_json | ||
location = Location.new(latitude: 25.779510, longitude: -80.338631, name: "Miami Store", address: "820 NW 87th Ave, Miami, FL") | ||
assert_equal({ latitude: 25.779510, longitude: -80.338631, name: "Miami Store", address: "820 NW 87th Ave, Miami, FL" }, location.to_json) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters