-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
124 additions
and
119 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
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
<?php | ||
/** | ||
* Currency Converter plugin for Craft CMS | ||
* | ||
* @author Leo Leoncio | ||
* @see https://github.com/leowebguy | ||
* @copyright Copyright (c) 2023, leowebguy | ||
* @license MIT | ||
*/ | ||
|
||
namespace leowebguy\currencyconverter\models; | ||
|
||
use craft\base\Model; | ||
|
||
class CurrencyModel extends Model | ||
{ | ||
public string $accessKey = '$CC_KEY'; | ||
public int $cacheTime = 6; | ||
} |
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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
{% import '_includes/forms' as forms %} | ||
|
||
{{ forms.autosuggestField({ | ||
first: true, | ||
name: 'accessKey', | ||
label: "Access Key", | ||
instructions: "Enter your access key from https://rapidapi.com/natkapral/api/currency-converter5 in this field"|t, | ||
required: true, | ||
suggestEnvVars: true, | ||
value: settings.accessKey, | ||
size: 64 | ||
first: true, | ||
name: 'accessKey', | ||
label: "Access Key", | ||
instructions: "Enter your access key from https://rapidapi.com/natkapral/api/currency-converter5 in this field"|t, | ||
required: true, | ||
suggestEnvVars: true, | ||
value: settings.accessKey, | ||
size: 64 | ||
}) }} | ||
|
||
{{ forms.selectField({ | ||
first: true, | ||
name: "cacheTime", | ||
label: "Cache Time", | ||
instructions: "Select how many hours the plugin should cache the currency rate"|t, | ||
options: { | ||
1: "1 hour", | ||
3: "3 hours", | ||
6: "6 hours", | ||
12: "12 hours", | ||
24: "24 hours" | ||
}, | ||
value: settings.cacheTime | ||
first: true, | ||
name: "cacheTime", | ||
label: "Cache Time", | ||
instructions: "Select how many hours the plugin should cache the currency rate"|t, | ||
options: { | ||
1: "1 hour", | ||
3: "3 hours", | ||
6: "6 hours", | ||
12: "12 hours", | ||
24: "24 hours" | ||
}, | ||
value: settings.cacheTime | ||
}) }} | ||
|
||
{# {{ forms.lightswitchField({ | ||
first: true, | ||
name: 'https', | ||
label: "Use HTTPS", | ||
instructions: "Whether API requests should be made using HTTPS instead of HTTP"|t, | ||
on: settings.https | ||
first: true, | ||
name: 'https', | ||
label: "Use HTTPS", | ||
instructions: "Whether API requests should be made using HTTPS instead of HTTP"|t, | ||
on: settings.https | ||
}) }} #} |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
<?php | ||
/** | ||
* Currency Converter plugin for Craft CMS | ||
* | ||
* @author Leo Leoncio | ||
* @see https://github.com/leowebguy | ||
* @copyright Copyright (c) 2023, leowebguy | ||
* @license MIT | ||
*/ | ||
|
||
namespace leowebguy\currencyconverter\variables; | ||
|
||
use leowebguy\currencyconverter\Currency; | ||
|
||
class CurrencyVariable | ||
{ | ||
/** | ||
* @param string $from | ||
* @param string $to | ||
* @param float|int $amount | ||
* @return mixed | ||
*/ | ||
public function conversion(string $from = 'EUR', string $to = 'USD', float|int $amount = 1): mixed | ||
{ | ||
return Currency::$plugin->currencyService->getConversion($from, $to, $amount); | ||
} | ||
} |