Skip to content

Commit

Permalink
refactor(ios): user setAttr rename to with function
Browse files Browse the repository at this point in the history
  • Loading branch information
SSebo committed Aug 2, 2022
1 parent 626c07e commit 87acf2c
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
2 changes: 1 addition & 1 deletion FeatureProbe.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FeatureProbe'
s.version = '1.0.1'
s.version = '1.1.0'
s.license = { :type => 'MIT' }
s.homepage = 'https://github.com/FeatureProbe/FeatureProbe'
s.authors = { 'featureprobe' => '[email protected]' }
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,95 +46,99 @@ typedef struct RustCallStatus {
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
#endif // def UNIFFI_SHARED_H

void ffi_featureprobe_17ce_FeatureProbe_object_free(
void ffi_featureprobe_e5_FeatureProbe_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FeatureProbe_new(
void*_Nonnull featureprobe_e5_FeatureProbe_new(
void*_Nonnull config,void*_Nonnull user,
RustCallStatus *_Nonnull out_status
);
int8_t featureprobe_17ce_FeatureProbe_bool_value(
void*_Nonnull featureprobe_e5_FeatureProbe_new_for_test(
RustBuffer toggles,
RustCallStatus *_Nonnull out_status
);
int8_t featureprobe_e5_FeatureProbe_bool_value(
void*_Nonnull ptr,RustBuffer key,int8_t default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_bool_detail(
RustBuffer featureprobe_e5_FeatureProbe_bool_detail(
void*_Nonnull ptr,RustBuffer key,int8_t default_value,
RustCallStatus *_Nonnull out_status
);
double featureprobe_17ce_FeatureProbe_number_value(
double featureprobe_e5_FeatureProbe_number_value(
void*_Nonnull ptr,RustBuffer key,double default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_number_detail(
RustBuffer featureprobe_e5_FeatureProbe_number_detail(
void*_Nonnull ptr,RustBuffer key,double default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_string_value(
RustBuffer featureprobe_e5_FeatureProbe_string_value(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_string_detail(
RustBuffer featureprobe_e5_FeatureProbe_string_detail(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_json_value(
RustBuffer featureprobe_e5_FeatureProbe_json_value(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_json_detail(
RustBuffer featureprobe_e5_FeatureProbe_json_detail(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPUser_object_free(
void ffi_featureprobe_e5_FPUser_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FPUser_new(
void*_Nonnull featureprobe_e5_FPUser_new(
RustBuffer key,
RustCallStatus *_Nonnull out_status
);
void featureprobe_17ce_FPUser_set_attr(
void featureprobe_e5_FPUser_with(
void*_Nonnull ptr,RustBuffer key,RustBuffer value,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPUrl_object_free(
void ffi_featureprobe_e5_FPUrl_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPUrlBuilder_object_free(
void ffi_featureprobe_e5_FPUrlBuilder_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FPUrlBuilder_new(
void*_Nonnull featureprobe_e5_FPUrlBuilder_new(
RustBuffer remote_url,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FPUrlBuilder_build(
RustBuffer featureprobe_e5_FPUrlBuilder_build(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPConfig_object_free(
void ffi_featureprobe_e5_FPConfig_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FPConfig_new(
void*_Nonnull featureprobe_e5_FPConfig_new(
void*_Nonnull remote_url,RustBuffer client_sdk_key,uint8_t refresh_interval,int8_t wait_first_resp,
RustCallStatus *_Nonnull out_status
);
RustBuffer ffi_featureprobe_17ce_rustbuffer_alloc(
RustBuffer ffi_featureprobe_e5_rustbuffer_alloc(
int32_t size,
RustCallStatus *_Nonnull out_status
);
RustBuffer ffi_featureprobe_17ce_rustbuffer_from_bytes(
RustBuffer ffi_featureprobe_e5_rustbuffer_from_bytes(
ForeignBytes bytes,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_rustbuffer_free(
void ffi_featureprobe_e5_rustbuffer_free(
RustBuffer buf,
RustCallStatus *_Nonnull out_status
);
RustBuffer ffi_featureprobe_17ce_rustbuffer_reserve(
RustBuffer ffi_featureprobe_e5_rustbuffer_reserve(
RustBuffer buf,int32_t additional,
RustCallStatus *_Nonnull out_status
);
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,95 +46,99 @@ typedef struct RustCallStatus {
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
#endif // def UNIFFI_SHARED_H

void ffi_featureprobe_17ce_FeatureProbe_object_free(
void ffi_featureprobe_e5_FeatureProbe_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FeatureProbe_new(
void*_Nonnull featureprobe_e5_FeatureProbe_new(
void*_Nonnull config,void*_Nonnull user,
RustCallStatus *_Nonnull out_status
);
int8_t featureprobe_17ce_FeatureProbe_bool_value(
void*_Nonnull featureprobe_e5_FeatureProbe_new_for_test(
RustBuffer toggles,
RustCallStatus *_Nonnull out_status
);
int8_t featureprobe_e5_FeatureProbe_bool_value(
void*_Nonnull ptr,RustBuffer key,int8_t default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_bool_detail(
RustBuffer featureprobe_e5_FeatureProbe_bool_detail(
void*_Nonnull ptr,RustBuffer key,int8_t default_value,
RustCallStatus *_Nonnull out_status
);
double featureprobe_17ce_FeatureProbe_number_value(
double featureprobe_e5_FeatureProbe_number_value(
void*_Nonnull ptr,RustBuffer key,double default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_number_detail(
RustBuffer featureprobe_e5_FeatureProbe_number_detail(
void*_Nonnull ptr,RustBuffer key,double default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_string_value(
RustBuffer featureprobe_e5_FeatureProbe_string_value(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_string_detail(
RustBuffer featureprobe_e5_FeatureProbe_string_detail(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_json_value(
RustBuffer featureprobe_e5_FeatureProbe_json_value(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FeatureProbe_json_detail(
RustBuffer featureprobe_e5_FeatureProbe_json_detail(
void*_Nonnull ptr,RustBuffer key,RustBuffer default_value,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPUser_object_free(
void ffi_featureprobe_e5_FPUser_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FPUser_new(
void*_Nonnull featureprobe_e5_FPUser_new(
RustBuffer key,
RustCallStatus *_Nonnull out_status
);
void featureprobe_17ce_FPUser_set_attr(
void featureprobe_e5_FPUser_with(
void*_Nonnull ptr,RustBuffer key,RustBuffer value,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPUrl_object_free(
void ffi_featureprobe_e5_FPUrl_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPUrlBuilder_object_free(
void ffi_featureprobe_e5_FPUrlBuilder_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FPUrlBuilder_new(
void*_Nonnull featureprobe_e5_FPUrlBuilder_new(
RustBuffer remote_url,
RustCallStatus *_Nonnull out_status
);
RustBuffer featureprobe_17ce_FPUrlBuilder_build(
RustBuffer featureprobe_e5_FPUrlBuilder_build(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_FPConfig_object_free(
void ffi_featureprobe_e5_FPConfig_object_free(
void*_Nonnull ptr,
RustCallStatus *_Nonnull out_status
);
void*_Nonnull featureprobe_17ce_FPConfig_new(
void*_Nonnull featureprobe_e5_FPConfig_new(
void*_Nonnull remote_url,RustBuffer client_sdk_key,uint8_t refresh_interval,int8_t wait_first_resp,
RustCallStatus *_Nonnull out_status
);
RustBuffer ffi_featureprobe_17ce_rustbuffer_alloc(
RustBuffer ffi_featureprobe_e5_rustbuffer_alloc(
int32_t size,
RustCallStatus *_Nonnull out_status
);
RustBuffer ffi_featureprobe_17ce_rustbuffer_from_bytes(
RustBuffer ffi_featureprobe_e5_rustbuffer_from_bytes(
ForeignBytes bytes,
RustCallStatus *_Nonnull out_status
);
void ffi_featureprobe_17ce_rustbuffer_free(
void ffi_featureprobe_e5_rustbuffer_free(
RustBuffer buf,
RustCallStatus *_Nonnull out_status
);
RustBuffer ffi_featureprobe_17ce_rustbuffer_reserve(
RustBuffer ffi_featureprobe_e5_rustbuffer_reserve(
RustBuffer buf,int32_t additional,
RustCallStatus *_Nonnull out_status
);
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import FeatureProbe

let url = FpUrlBuilder(remoteUrl: "remote_url").build();
let user = FpUser(key: "key123")
user.setAttr(key: "city", value: "1")
user.with(key: "city", value: "1")
let config = FpConfig(
remoteUrl: url!,
clientSdkKey: "client-9d885a68ca2955dfb3a7c95435c0c4faad70b50d",
Expand Down Expand Up @@ -44,6 +44,7 @@ NSLog(@"value is %@", value);
```
## Build
build from repo: `[email protected]:FeatureProbe/client-sdk-mobile.git`
1. install uniffi codegen tool
Expand All @@ -68,8 +69,26 @@ git commit -m 'xxx'
git push origin master
```
## Unit Testing
```swift
let fp2 = FeatureProbe.newForTest(toggles: "{ \"toggle_1\": true }")
let is_true = fp2.boolValue(key: "toggle_1", defaultValue: false)
assert(is_true == true);
```

```objective-c
#import "FeatureProbe-Swift.h"

NSString *s = @"{ \"ab_test\": \"green\"}";
FeatureProbe *fp = [[FeatureProbe alloc] initWithTestJson: s];
NSString *value = [fp stringValueWithKey:@"ab_test" defaultValue:@"red"];
NSLog(@"value is %@", value);
```
## Contributing
We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
community for contributing bugfixes and improvements.
Expand Down
Loading

0 comments on commit 87acf2c

Please sign in to comment.