Skip to content

Commit ce9cc09

Browse files
made it so the API can be set as explicit param in each fxn call and that all creds are explicitly passed into area calls
1 parent 3e4ff84 commit ce9cc09

64 files changed

Lines changed: 598 additions & 1113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: aWhereAPI
22
Title: API calls for aWhere API
3-
Version: 0.6.32
3+
Version: 0.6.33
44
Authors@R:
55
c(person("Technical", "Support", ,"[email protected]", role = c("aut","cre","ctb")))
66
Description:
@@ -10,7 +10,7 @@ Description:
1010
and forecast data.
1111
License: MIT, Copyright 2016 aWhere
1212
LazyData: true
13-
RoxygenNote: 6.1.1
13+
RoxygenNote: 7.1.1
1414
Depends:
1515
R (>= 3.3.2)
1616
Imports:

R/agronomic-crops.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
2222
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
2323
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
24+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
2425
#'
2526
#' @import httr
2627
#'
@@ -34,14 +35,15 @@
3435
#' @export
3536

3637
get_crops <- function(crop_id = ''
37-
,keyToUse = awhereEnv75247$uid
38-
,secretToUse = awhereEnv75247$secret
39-
,tokenToUse = awhereEnv75247$token) {
38+
,keyToUse = awhereEnv75247$uid
39+
,secretToUse = awhereEnv75247$secret
40+
,tokenToUse = awhereEnv75247$token
41+
,apiAddressToUse = awhereEnv75247$apiAddress) {
4042

4143
checkCredentials(keyToUse,secretToUse,tokenToUse)
4244

4345
## Create Request
44-
url <- paste0(awhereEnv75247$apiAddress, "/agronomics/crops/")
46+
url <- paste0(apiAddressToUse, "/agronomics/crops/")
4547

4648
if(crop_id != "") {
4749
url <- paste0(url, crop_id)

R/agronomic-norms.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
6666
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
6767
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
68+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
6869
#'
6970
#' @import httr
7071
#' @import data.table
@@ -104,7 +105,8 @@ agronomic_norms_fields <- function(field_id
104105
,includeFeb29thData = TRUE
105106
,keyToUse = awhereEnv75247$uid
106107
,secretToUse = awhereEnv75247$secret
107-
,tokenToUse = awhereEnv75247$token) {
108+
,tokenToUse = awhereEnv75247$token
109+
,apiAddressToUse = awhereEnv75247$apiAddress) {
108110

109111
#############################################################
110112
#Checking Input Parameters
@@ -189,7 +191,7 @@ agronomic_norms_fields <- function(field_id
189191
##############################################################################
190192

191193
# Create query
192-
urlAddress <- paste0(awhereEnv75247$apiAddress, "/agronomics")
194+
urlAddress <- paste0(apiAddressToUse, "/agronomics")
193195

194196
strBeg <- paste0('/fields')
195197
strCoord <- paste0('/',field_id)
@@ -400,6 +402,7 @@ agronomic_norms_fields <- function(field_id
400402
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
401403
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
402404
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
405+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
403406
#'
404407
#' @import httr
405408
#' @import data.table
@@ -443,7 +446,8 @@ agronomic_norms_latlng <- function(latitude
443446
,includeFeb29thData = TRUE
444447
,keyToUse = awhereEnv75247$uid
445448
,secretToUse = awhereEnv75247$secret
446-
,tokenToUse = awhereEnv75247$token) {
449+
,tokenToUse = awhereEnv75247$token
450+
,apiAddressToUse = awhereEnv75247$apiAddress) {
447451

448452
#############################################################
449453
#Checking Input Parameters
@@ -528,7 +532,7 @@ agronomic_norms_latlng <- function(latitude
528532
##############################################################################
529533

530534
# Create query
531-
urlAddress <- paste0(awhereEnv75247$apiAddress, "/agronomics")
535+
urlAddress <- paste0(apiAddressToUse, "/agronomics")
532536

533537
strBeg <- paste0('/locations')
534538
strCoord <- paste0('/',latitude,',',longitude)
@@ -757,6 +761,7 @@ agronomic_norms_latlng <- function(latitude
757761
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
758762
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
759763
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
764+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
760765
#'
761766
#' @import httr
762767
#' @import data.table
@@ -806,7 +811,8 @@ agronomic_norms_area <- function(polygon
806811
,maxTryCount = 3
807812
,keyToUse = awhereEnv75247$uid
808813
,secretToUse = awhereEnv75247$secret
809-
,tokenToUse = awhereEnv75247$token) {
814+
,tokenToUse = awhereEnv75247$token
815+
,apiAddressToUse = awhereEnv75247$apiAddress) {
810816

811817
#Checking Input Parameters
812818
checkCredentials(keyToUse,secretToUse,tokenToUse)
@@ -893,7 +899,11 @@ agronomic_norms_area <- function(polygon
893899
,gdd_base_temp = gdd_base_temp
894900
,gdd_min_boundary = gdd_min_boundary
895901
,gdd_max_boundary = gdd_max_boundary
896-
,includeFeb29thData = includeFeb29thData)
902+
,includeFeb29thData = includeFeb29thData
903+
,keyToUse = keyToUse
904+
,secretToUse = secretToUse
905+
,tokenToUse = tokenToUse
906+
,apiAddressToUse = apiAddressToUse)
897907

898908
currentNames <- colnames(t)
899909

R/agronomic-values.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#' @param - keyToUse: aWhere API uid to use. For advanced use only. Most users will not need to use this parameter (optional)
5353
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
5454
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
55+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
5556
#'
5657
#' @import httr
5758
#' @import data.table
@@ -81,7 +82,8 @@ agronomic_values_fields <- function(field_id
8182
,gdd_max_boundary = 30
8283
,keyToUse = awhereEnv75247$uid
8384
,secretToUse = awhereEnv75247$secret
84-
,tokenToUse = awhereEnv75247$token) {
85+
,tokenToUse = awhereEnv75247$token
86+
,apiAddressToUse = awhereEnv75247$apiAddress) {
8587

8688
checkCredentials(keyToUse,secretToUse,tokenToUse)
8789
checkValidField(field_id,keyToUse,secretToUse,tokenToUse)
@@ -131,7 +133,7 @@ agronomic_values_fields <- function(field_id
131133
}
132134

133135
# Create query
134-
urlAddress <- paste0(awhereEnv75247$apiAddress, "/agronomics")
136+
urlAddress <- paste0(apiAddressToUse, "/agronomics")
135137

136138
strBeg <- paste0('/fields')
137139
strCoord <- paste0('/',field_id)
@@ -312,6 +314,7 @@ agronomic_values_fields <- function(field_id
312314
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
313315
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
314316
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
317+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
315318
#'
316319
#' @import httr
317320
#' @import data.table
@@ -340,7 +343,8 @@ agronomic_values_latlng <- function(latitude
340343
,gdd_max_boundary = 30
341344
,keyToUse = awhereEnv75247$uid
342345
,secretToUse = awhereEnv75247$secret
343-
,tokenToUse = awhereEnv75247$token) {
346+
,tokenToUse = awhereEnv75247$token
347+
,apiAddressToUse = awhereEnv75247$apiAddress) {
344348

345349
checkCredentials(keyToUse,secretToUse,tokenToUse)
346350
checkValidLatLong(latitude,longitude)
@@ -390,7 +394,7 @@ agronomic_values_latlng <- function(latitude
390394
}
391395

392396
# Create query
393-
urlAddress <- paste0(awhereEnv75247$apiAddress, "/agronomics")
397+
urlAddress <- paste0(apiAddressToUse, "/agronomics")
394398

395399
strBeg <- paste0('/locations')
396400
strCoord <- paste0('/',latitude,',',longitude)
@@ -587,6 +591,7 @@ agronomic_values_latlng <- function(latitude
587591
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
588592
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
589593
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
594+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
590595
#'
591596
#' @import httr
592597
#' @import data.table
@@ -624,7 +629,8 @@ agronomic_values_area <- function(polygon
624629
,maxTryCount = 3
625630
,keyToUse = awhereEnv75247$uid
626631
,secretToUse = awhereEnv75247$secret
627-
,tokenToUse = awhereEnv75247$token) {
632+
,tokenToUse = awhereEnv75247$token
633+
,apiAddressToUse = awhereEnv75247$apiAddress) {
628634

629635
checkCredentials(keyToUse,secretToUse,tokenToUse)
630636
checkValidStartEndDatesAgronomics(day_start,day_end)
@@ -699,7 +705,11 @@ agronomic_values_area <- function(polygon
699705
,longitude = grid[[j]]$lon
700706
,day_start = day_start
701707
,day_end = day_end
702-
,propertiesToInclude = propertiesToInclude)
708+
,propertiesToInclude = propertiesToInclude
709+
,keyToUse = keyToUse
710+
,secretToUse = secretToUse
711+
,tokenToUse = tokenToUse
712+
,apiAddressToUse = apiAddressToUse)
703713

704714
currentNames <- colnames(t)
705715

R/create.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
2727
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
2828
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
29+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
2930
#'
3031
#' @return - printed text that informs if the query succeeded or not
3132
#'
@@ -49,7 +50,8 @@ create_field <- function(field_id
4950
,verbose = TRUE
5051
,keyToUse = awhereEnv75247$uid
5152
,secretToUse = awhereEnv75247$secret
52-
,tokenToUse = awhereEnv75247$token) {
53+
,tokenToUse = awhereEnv75247$token
54+
,apiAddressToUse = awhereEnv75247$apiAddress) {
5355

5456
#############################################################
5557
#Checking Input Parameters
@@ -67,7 +69,7 @@ create_field <- function(field_id
6769
farm_id <- gsub(' ','_',farm_id)
6870

6971
## Create Request
70-
url <- paste0(awhereEnv75247$apiAddress, "/fields")
72+
url <- paste0(apiAddressToUse, "/fields")
7173

7274
postbody <- paste0('{"id":"', field_id, '",',
7375
'"centerPoint":{"latitude":', latitude, ',"longitude":', longitude, '}',
@@ -147,6 +149,7 @@ create_field <- function(field_id
147149
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
148150
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
149151
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
152+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
150153
#'
151154
#' @return - system generated planting id along with a print text that informs if the query succeeded or not
152155
#'
@@ -173,7 +176,8 @@ create_planting <- function(field_id
173176
,verbose = TRUE
174177
,keyToUse = awhereEnv75247$uid
175178
,secretToUse = awhereEnv75247$secret
176-
,tokenToUse = awhereEnv75247$token) {
179+
,tokenToUse = awhereEnv75247$token
180+
,apiAddressToUse = awhereEnv75247$apiAddress) {
177181

178182
checkCredentials(keyToUse,secretToUse,tokenToUse)
179183
## Error checking for valid entries
@@ -188,7 +192,7 @@ create_planting <- function(field_id
188192

189193
checkValidField(field_id,keyToUse,secretToUse,tokenToUse)
190194

191-
url <- paste0(awhereEnv75247$apiAddress, "/agronomics/fields/", field_id, "/plantings")
195+
url <- paste0(apiAddressToUse, "/agronomics/fields/", field_id, "/plantings")
192196

193197
postbody <- paste0('{',
194198
'"crop":"', crop, '",',

R/delete.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
1414
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
1515
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
16+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
1617
#'
1718
#' @return - a print text that informs if the query succeded or not
1819
#'
@@ -28,12 +29,13 @@ delete_field <- function(field_id
2829
,verbose = TRUE
2930
,keyToUse = awhereEnv75247$uid
3031
,secretToUse = awhereEnv75247$secret
31-
,tokenToUse = awhereEnv75247$token) {
32+
,tokenToUse = awhereEnv75247$token
33+
,apiAddressToUse = awhereEnv75247$apiAddress) {
3234

3335
checkCredentials(keyToUse,secretToUse,tokenToUse)
3436
checkValidField(field_id,keyToUse,secretToUse,tokenToUse)
3537

36-
url <- paste0(awhereEnv75247$apiAddress, "/fields/", field_id)
38+
url <- paste0(apiAddressToUse, "/fields/", field_id)
3739

3840
postbody <- paste0('{', field_id, '}');
3941

@@ -78,6 +80,7 @@ delete_field <- function(field_id
7880
#' @param - keyToUse: aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)
7981
#' @param - secretToUse: aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)
8082
#' @param - tokenToUse: aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)
83+
#' @param - apiAddressToUse: Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)
8184
#'
8285
#' @return - a print text that informs if the query succeded or not
8386
#'
@@ -95,12 +98,13 @@ delete_planting <- function(field_id
9598
,verbose = TRUE
9699
,keyToUse = awhereEnv75247$uid
97100
,secretToUse = awhereEnv75247$secret
98-
,tokenToUse = awhereEnv75247$token) {
101+
,tokenToUse = awhereEnv75247$token
102+
,apiAddressToUse = awhereEnv75247$apiAddress) {
99103

100104
checkCredentials(keyToUse,secretToUse,tokenToUse)
101105
checkValidField(field_id,keyToUse,secretToUse,tokenToUse)
102106

103-
url <- paste0(awhereEnv75247$apiAddress, "/agronomics/fields/", field_id,'/plantings/',planting_id)
107+
url <- paste0(apiAddressToUse, "/agronomics/fields/", field_id,'/plantings/',planting_id)
104108

105109
doWeatherGet = TRUE
106110
while (doWeatherGet == TRUE) {

0 commit comments

Comments
 (0)