Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
weather_API_Assignment
Advanced tools
This API will provide latest information of current weather
This client library is a Ruby gem which can be compiled and used in your Ruby and Ruby on Rails project. This library requires a few gems from the RubyGems repository.
gem build weather_api_assignment.gemspec
to build the gem.gem install weather_api_assignment-1.0.gem
The following section explains how to use the WeatherApiAssignment Ruby Gem in a new Rails project using RubyMine™. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Close any existing projects in RubyMine™ by selecting File -> Close Project
. Next, click on Create New Project
to create a new project from scratch.
Next, provide TestApp
as the project name, choose Rails Application
as the project type, and click OK
.
In the next dialog make sure that correct Ruby SDK is being used (minimum 2.0.0) and click OK
.
This will create a new Rails Application project with an existing set of files and folder.
In order to use the WeatherApiAssignment gem in the new project we must add a gem reference. Locate the Gemfile
in the Project Explorer window under the TestApp
project node. The file contains references to all gems being used in the project. Here, add the reference to the library gem by adding the following line: gem 'weather_api_assignment', '~> 1.0'
Once the TestApp
project is created, a folder named controllers
will be visible in the Project Explorer under the following path: TestApp > app > controllers
. Right click on this folder and select New -> Run Rails Generator...
.
Selecting the said option will popup a small window where the generator names are displayed. Here, select the controller
template.
Next, a popup window will ask you for a Controller name and included Actions. For controller name provide Hello
and include an action named Index
and click OK
.
A new controller class anmed HelloController
will be created in a file named hello_controller.rb
containing a method named Index
. In this method, add code for initialization and a sample for its usage.
You can test the generated SDK and the server with automatically generated test cases as follows:
bundle exec rake
In order to setup authentication and initialization of the API client, you need the following information.
Parameter | Description |
---|---|
appid | App key for authentication |
API client can be initialized as following.
# Configuration parameters and credentials
appid = '178db63aed00f6e4daaa06009b04438b' # App key for authentication
client = WeatherApiAssignment::WeatherApiAssignmentClient.new(
appid: appid
)
The added initlization code can be debugged by putting a breakpoint in the Index
method and running the project in debug mode by selecting Run -> Debug 'Development: TestApp'
.
The singleton instance of the WeatherAPIsController
class can be accessed from the API Client.
weatherAPIs_controller = client.weather_ap_is
This is a weather API endpoint which returns the current weather of a location by city name.
def get_weather_by_city_name(q,
mode = nil,
units = nil,
lang = nil); end
Parameter | Tags | Description |
---|---|---|
q | Required DefaultValue | City name, state code and country code divided by comma, use ISO 3166 country codes. |
mode | Optional | Response format. Possible values are xml and html. If you don't use the mode parameter format is JSON by default. |
units | Optional | Units of measurement. standard, metric and imperial units are available. If you do not use the units parameter, standard units will be applied by default. |
lang | Optional | You can use this parameter to get the output in your language. |
q = 'London,uk'
mode = WeatherApiAssignment::MODEEnum::XML
units = WeatherApiAssignment::UNITSEnum::STANDARD
lang = WeatherApiAssignment::LANGEnum::AF
result = weatherAPIs_controller.get_weather_by_city_name(q, mode, units, lang)
This is a weather API endpoint which returns the current weather of a location by latitude and longitude.
def get_weather_by_latitude_and_longitude(lat,
lon,
mode = nil,
units = nil,
lang = nil); end
Parameter | Tags | Description |
---|---|---|
lat | Required | This field will contain the latitude of city |
lon | Required | This field will contain the longitude of city |
mode | Optional | Response format. Possible values are xml and html. If you don't use the mode parameter format is JSON by default. |
units | Optional | Units of measurement. standard, metric and imperial units are available. If you do not use the units parameter, standard units will be applied by default. |
lang | Optional | You can use this parameter to get the output in your language. |
lat = 29.0834359890239
lon = 29.0834359890239
mode = WeatherApiAssignment::MODEEnum::XML
units = WeatherApiAssignment::UNITSEnum::STANDARD
lang = 'lang'
result = weatherAPIs_controller.get_weather_by_latitude_and_longitude(lat, lon, mode, units, lang)
FAQs
Unknown package
We found that weather_API_Assignment demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.