@@ -32,6 +32,27 @@ function findConfigurationById($id) {
32
32
throw new Exception ("Unable to find a Configuration with id( " . $ id . ") " );
33
33
}
34
34
35
+ function findConfigurationByName ($ name ) {
36
+ $ response = $ this ->executeRequest ("configurations/name/ " . $ name );
37
+
38
+ $ this ->handleError ($ response );
39
+ $ configurations = $ response ->body ->data ;
40
+
41
+ if (count ($ configurations ) > 0 ) {
42
+ return $ configurations [0 ];
43
+ }
44
+
45
+ throw new Exception ("Unable to find a Configuration with name( " . $ id . ") " );
46
+ }
47
+
48
+ function findConfigurationByPath ($ path ) {
49
+ $ response = $ this ->executeRequest ("configurations/path/ " . $ path );
50
+
51
+ $ this ->handleError ($ response );
52
+
53
+ return $ response ->body ->data ;
54
+ }
55
+
35
56
function executeRequest ($ path ) {
36
57
return Httpful \Request::get ($ this ->apiUrl . "/ " . $ path )
37
58
->addHeader ("Authorization " , "Bearer " . $ this ->appId . ": " . $ this ->appSecret )
@@ -40,15 +61,19 @@ function executeRequest($path) {
40
61
41
62
function handleError ($ response ) {
42
63
if ($ response ->body ->success == false ) {
64
+ print_r ($ response );
65
+
43
66
throw new Exception ("Failed to fetch configuration " );
44
67
}
45
68
}
46
69
}
47
70
48
71
// pls remove this below
49
72
$ nonfig = new Nonfig ("f1afd7c6-c570-4fc0-a08a-5ed65bf9811e " , "cT99KHl4kT17ewFotCef " );
50
- $ config = $ nonfig ->findConfigurationById ("8400a3a0-9c14-47cc-b598-f5037fd5a9ce " );
73
+ $ configId = $ nonfig ->findConfigurationById ("8400a3a0-9c14-47cc-b598-f5037fd5a9ce " );
74
+ $ configName = $ nonfig ->findConfigurationByName ("/feature_flags " );
75
+ $ configPath = $ nonfig ->findConfigurationByPath ("i18n " );
51
76
52
- print_r ($ config );
77
+ print_r ($ configPath );
53
78
54
79
?>
0 commit comments